I'm having trouble learning how to import data from a site using HTTP get in node js. The GET would be accessing an array of objects contained in the key of root JSON object returned.
Two things that confuse me are how to use my query key in this process/how to act on or access the array information that the get would return. Thanks a lot
My code so far is as follows:
var http = require('http');
var options = {
host: 'site',
path: 'path'
};
callback = function(response) {
var str = '';
//another chunk of data has been recieved, so append it to `str`
response.on('data', function (chunk) {
str += chunk;
});
//the whole response has been recieved, so we just print it out here
response.on('end', function () {
console.log(str);
});
}
http.request(options, callback).end();
via user7910719
No comments:
Post a Comment