Я пытаюсь сделать вызов https в Node JS. Вот звонок:
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();
Следовательно, я ожидаю POST-вызов этого URL: "https://example.net/abc/test
" с прикрепленным телом, но, к моему удивлению, я всегда получаю эту ошибку: Network Error with the HTTP Call. Error: getaddrinfo ENOTFOUND https://example.net https://example.net:443
, что подразумевает, что сам звонок не проходит, хотя соединение, кажется, работает, как я могу нажать от Почтальона. Что-то не так с вызовом https?