I am developing a simple nodejs application. I am trying to make a REST API call from that application an the REST API has basic authentication. I am getting error "ERRORError: getaddrinfo ENOTFOUND" Tried with the options suggested in stackoverflow but couldn't make it work. Can anyone please help me on this..Here is the code I am using `
var http = require('http');
var url = 'someurl';
var username = 'username';
var password = 'password';
var optionsget = {
host: 'someurl',
method: 'GET',
auth: username + ':' + password,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
};
console.log('Do the GET call');
// do the GET request
var reqGet = http.get(optionsget, function(res) {
console.log("Hii");
console.log("statusCode: ", res.statusCode);
res.on('data', function(d) {
console.info('GET result:\n');
process.stdout.write(d);
console.info('\n\nCall completed');
});
});
reqGet.end();
reqGet.on('error', function(e) {
console.error("ERROR" +e);
});
Thanks in advance
Regards
VHC