I'm trying to make a https call in Node JS. Here is the call:
var options = {
hostname: "https://example.net",
path: "/abc/test",
method : 'POST',
headers: {
"Content-Type": "application/x-www-form-urlencoded"
}
};
const req = https.request(options, (res: any) => {
res.setEncoding('utf8');
res.on('data', (chunk: any) => {
// Some Processing on response
});
});
req.on('error', (error: any) => {
console.log("Network Error with the HTTP Call. Error: " + error.message);
});
req.write('resource=rs1&query1=sample1&query2=sample2');
req.end();
Hence, I'm expecting a POST call to this url: "https://example.net/abc/test
" with the body attached, but to my surprise, I'm always getting this error: Network Error with the HTTP Call. Error: getaddrinfo ENOTFOUND https://example.net https://example.net:443
which implies the call itself is not going through, although the connection seems to be working as I can hit from Postman. Is there anything wrong with the https call?