Skip to content

Latest commit

 

History

History
33 lines (25 loc) · 419 Bytes

express.md

File metadata and controls

33 lines (25 loc) · 419 Bytes

Return response as HTML:

response.send('HTML <br> here');

Return response as JSON:

response.json({foo: 'bar'});
// or
response.send({foo: 'bar'});

Return error response with a JSON payload:

response
  .status(500)
  .json({
    error: 'message'
  });

Return an empty response (i.e. no response body):

response
  .status(401)
  .end();