custom API
Custom APIs
Basic code
- Custom API has the async 'main' function. In which users will write their custom logic.
await
- Write 'await' before the global object 'g' to write asynchronous code.
- Without 'await' it can be created problems.
true
- Write 'true' that will help to non-stop execution of the custom API if that API gets an error response.
- If the user does not write the 'true' it will stop the execution and throw the error.
- One more use of 'true' is it will return whole response not only response data.
Throw error
- In custom API user can throw an error using the 'throw' keyword.
Get file
- You can create a custom API that will download files for the application user.