Skip to content

Instantly share code, notes, and snippets.

@Checksum
Created July 27, 2012 06:36
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Checksum/3186477 to your computer and use it in GitHub Desktop.
Save Checksum/3186477 to your computer and use it in GitHub Desktop.
Node.js get JSON response
require('http').request({
host: 'example.com',
path: '/path/to/get',
method: 'GET'
}, function(res) {
res.setEncoding('utf8');
var body = '';
res.on('data', function(chunk) {
body += chunk;
});
res.on('end', function() {
body = JSON.parse(body);
// Do stuff here
}
}).end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment