express - How to GET json data from API with a header -
i'm trying json data api using nodejs , express, requires header i'm not sure how input header request.
the documentation says:
curl -h"x-fullcontact-apikey:$your_key" 'https://api.fullcontact.com/v2/person.json?email=bart@fullcontact.com'
how do add request header? looked everywhere on stackoverflow days, , havent found anything. php, nothing nodejs w/ express. how can request node npm manager package
not sure on how request code looks like, should it; right?
var request = require('request'); var options = { url: 'https://api.fullcontact.com/v2/person.json?email=bart@fullcontact.com', headers: { 'x-fullcontact-apikey': '$your_key' } }; function callback(error, response, body) { if (!error && response.statuscode == 200) { var result = json.parse(body); console.log(result); } } request(options, callback);
Comments
Post a Comment