I have a code like this:
var options = {
host: "https://basic:authentication@website.com",
path: "/api/address"
};
var request = https.get(options, function(response){
var str = "";
response.on('data', function(chunk){
str+=chunk;
});
response.on('end', function(){
console.log(str);
res.json(str);
});
});
request.end();
request.on('error', function(err){
console.log(err);
});
This gives me
{ [Error: getaddrinfo ENOTFOUND] code: 'ENOTFOUND', errno: 'ENOTFOUND', syscall: 'getaddrinfo' }
I don't know what's wrong because if I change the request to look like this:
var request = https.get("https://basic:authentication@website.com/api/address", function(response){
It works and gets an answer from the api. The problem is that I can't input parameters into the call if I do it this way. Does anyone have tips?