it always gives :
Error: getaddrinfo ENOTFOUND <hostname without http or https>
at errnoException (dns.js:44:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:26)
STATUS: undefined
My code is as follows:-
var Http = require('https');
var str = "";
var options = {
hostname: '<host name without http or https>',
path: '<path>',
method: 'POST',
headers: {
'Content-Type': 'application/json;charset:utf-8',
'Content-Length': payload.length,
'User-Agent': 'Node.js/0.12.7',
'Proxy-Connections': 'keep-alive'
}
};
var req = Http.request(options, function(res) {
res.setEncoding('utf-8');
res.on('data', function(response) {
str += response;
});
res.on('end', function() {
return exits.success(str);
});
});
req.on('error', function(e) {
console.log('STATUS: ' + e.statusCode);
exits.error('problem with request: ' + e.message);
});
req.write(payload);
req.end();
I have already tried following:-
- setting proxy and https-proxy
- removing http or https from host name
Please help me resolving this issue.
hostnameandpathin theoptionsobject.