NodeJS HttpGet to a URL with JSON response

request is now deprecated. It is recommended you use an alternative:

Stats comparision
Some code examples

Original answer:

The request module makes this really easy. Install request into your package from npm, and then you can make a get request.

var request = require("request")

var url = "" +
    "key=d99803c970a04223998cabd90a741633" +

    url: url,
    json: true
}, function (error, response, body) {

    if (!error && response.statusCode === 200) {
        console.log(body) // Print the json response

You can find documentation for request on npm:

Leave a Comment