Skip to content

sorribas/send-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

send-json

build status

Send objects as JSON over http.

Example

var http = require('http');
var sendJson = require('send-json');

var server = http.createServer(function(req, res) {
  sendJson(res, {hello: 'world'});
});

server.listen(3000);

Or you can just add a send function to the http response object like this.

var http = require('http');
var sendJson = require('send-json');

var server = http.createServer(function(req, res) {
  res.send = sendJson.bind(null, res);

  res.send({hello: 'world'});
});

server.listen(3000);

License

MIT License

About

Node.js module to send objects as JSON over http.

Resources

License

Stars

Watchers

Forks

Packages

No packages published