sw-json
Convenience middleware for sending JSON. Adds a .json()
method to the res
object which responds with a JSON body.
Install
npm install sw-json
Example
var json = ; // With expressapp; var NOTFOUND = JSON;// or use as inline middlewareapp;
API
res.json(body, [code])
- body - JavaScript object or JSON formatted string
- code - Status code, optional, defaults to 200