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

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.

// Script
response.error("Security code is not valid", 401);
// Result
Security code is not valid
// HTTP response code
401