Error: getaddrinfo ENOTFOUND jsonplaceholder.typicode.com/ jsonplaceholder.typicode.com/:80
at errnoException (dns.js:28:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
我的代码看起来像这样 -
var test = await new Promise((resolve, reject) => {
var options = {
host: 'jsonplaceholder.typicode.com/',
path: '/posts/1'
};
var req = http.request(options);
req.end();
req.on('connect', (res, socket, head) => {
socket.on('data', (chunk) => {
resolve(chunk.toString());
});
socket.on('end', () => {
proxy.close();
});
});
});
似乎端口号存在问题,但我无法弄清楚,请帮我确定问题。
答案 0 :(得分:1)
从选项的主机属性中删除尾部斜杠