Unirest library simplifies this a lot. If you want to use it, you have to install unirest
npm package. Then your code could look like this:
unirest.get("http://graph.facebook.com/517267866/?fields=picture")
.send()
.end(response=> {
if (response.ok) {
console.log("Got a response: ", response.body.picture)
} else {
console.log("Got an error: ", response.error)
}
})