NodeJS HttpGet to a URL with JSON response NodeJS HttpGet to a URL with JSON response json json

NodeJS HttpGet to a URL with JSON response


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

Stats comparisionSome 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 = "http://developer.cumtd.com/api/v2.2/json/GetStop?" +    "key=d99803c970a04223998cabd90a741633" +    "&stop_id=it"request({    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: https://npmjs.org/package/request