Created
March 9, 2016 13:34
-
-
Save diem1/e37557afb3f13ae00010 to your computer and use it in GitHub Desktop.
NodeJS Json Parse (http.get)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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