Wondering how I can make a GET request to a JSON API using Node.js. I preferably want to use Express however it is not necessary, and for the output to be on a Jade page. I\'m s
Also, the same people who brought you the request
package, have come out with a promise based version backed by bluebird called, not surprisingly, request-promise
:
request-promise npm page
Some folks also prefer super agent, which allows you to chain commands:
superagent npm page
Here's an example from their docs:
request
.post('http://localhost:3000/api/pet')
.send({ name: 'Manny', species: 'cat' })
.set('X-API-Key', 'foobar')
.set('Accept', 'application/json')
.end(function(err, res){
// Calling the end function will send the request
});