我试图从我的localhost发送对我的localhost的请求,如下所示:
http.get
host: 'localhost:3000'
path: '/events'
, (response) ->
console.log response
这导致此错误:
Error: getaddrinfo ENOTFOUND localhost:3000:80 localhost:3000:80:80
at errnoException (dns.js:26:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:77:26)
我无法弄清楚为什么会发生以及如何修复。我不能发送同一台服务器的请求吗?
感谢。
答案 0 :(得分:1)
localhost:3000
不是主持人;它是一个主机和一个端口。将它们作为单独的属性传递。
http.get
host: 'localhost'
port: 3000
path: '/events'
, (response) ->
console.log response