response.error(body)
Returns an error response with a specified body and error code (HTTP response status).
Parameters
The method has the following parameters
Parameter | Description |
---|---|
body | Response body as string, number, boolean, array, object. |
code | HTTP error code (string or number). More information. |
Example
Returning an error response.
response.error("Security code is not valid", 401);
Security code is not valid
401