我对 Node.js 很陌生,所以这可能是一个基本的理解问题,但是ECONNREFUSED
当我认为我不应该这样做时,我是从超级代理 http 请求中获取的:
$ curl http://localhost:5000/
{"you": "looking good"}
$ node
> var request = require("superagent");
> var req = request.get("http://localhost:5000/").on('error', function (err) {
console.log("There's an emergency is going on.", err)
}).end(function (data) {
console.log("All is well", data.body)
});
There's an emergency is going on. { [Error: connect ECONNREFUSED]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect' }
我做了什么假设打破了这一点?我实际上正在编写同构 JavaScript 和完全相同的代码,使浏览器上的 http 查询工作正常!