I am attempting to make a http request to news.google.com using the native node.js
http
module. I am getting theconnect ECONNREFUSED 127.0.0.1:80
error when I tried the following
var http = require('http');
var payload = JSON.stringify({
name: 'John Smith',
email: '[email protected]',
resume: 'https://drive.google.com/open?id=asgsaegsehsehseh'
});
var options = {
hostname: 'https://news.google.com',
path: '/',
method: 'GET'
};
var httpRequest = http.request(options, function(request, response) {
console.log('STATUS', response.statusCode);
response.setEncoding('utf8');
response.on('data', function(chunk) {
console.log('BODY:', chunk);
});
response.on('end', function() {
console.log('No more data in response');
});
});
httpRequest.on('error', function(e) {
console.log('Error with the request:', e.message);
});
httpRequest.write(payload);
httpRequest.end();
Why am I getting this error?
I tried using the request
npm module. And it worked!