JSON Response With an HTTP Status Code
Use the status()
function to return JSON data with an HTTP status code.
This function is useful when returning errors.
Usage
status(..., status code)
Parameters:
The same as
respond()
.
Example
@get('/greet'):
if require_keys(['name', 'age'], body):
status('Please provide all required parameters.', 400)
respond({
name: body['name'],
age: body['age']
})
Last updated