error

response.error(body)

Returns an error response with a specified body and error code (HTTP response status).

Parameters

The method has the following parameters

ParameterDescription
bodyResponse body as string, number, boolean, array, object.
codeHTTP 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