I have written the following NodeJS code to retrieve the json object from a website
var http = require('http');
var url = {
host: 'www.sample-website.com',
headers: {
"Accept": "application/json",
'Content-Type': 'application/json'
},
};
http.get(url, function(obj) {
var output = "";
for (property in obj) {
output += property + obj[property] ;
}
console.log(output);
})
However as response I'm getting some code(some sort of events.js code) that I can't understand (not the HTML code). Need help figuring out where I'm going wrong
Including a snippet for reference ::
// emit removeListener for all listeners on all events
if (arguments.length === 0) {
for (key in this._events) {
if (key === 'removeListener') continue;
this.removeAllListeners(key);
}
this.removeAllListeners('removeListener');
this._events = {};
return this;
}