Skip to content

Instantly share code, notes, and snippets.

@diem1
Created March 9, 2016 13:34
Show Gist options
  • Save diem1/e37557afb3f13ae00010 to your computer and use it in GitHub Desktop.
Save diem1/e37557afb3f13ae00010 to your computer and use it in GitHub Desktop.
NodeJS Json Parse (http.get)
var url = 'http://graph.facebook.com/517267866/?fields=picture';
var http = require('http');
http.get(url, function(res){
var body = '';
res.on('data', function(chunk){
body += chunk;
});
res.on('end', function(){
var fbResponse = JSON.parse(body);
console.log("Got a response: ", fbResponse.picture);
});
}).on('error', function(e){
console.log("Got an error: ", e);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment