我正在尝试运行以下节点代码,
function getQuestions() {
var options = {
host: 'mysite.com',
path: '/services/v2/question.json',
headers: {
"Content-Type": "application/json",
"accept": "application/json; charset=UTF-8",
'Authorization': auth
}
};
http.request(options, function(response) {
console.log("Everything worked!");
}).on('error', function(e) {
console.log('problem with request: ' + e.stack);
});
}
但总是错误说......
problem with request: Error: connect ECONNREFUSED
at errnoException (net.js:905:11)
at Object.afterConnect [as oncomplete] (net.js:896:19)
当我将相同的信息放入邮递员时它工作正常。有没有办法调试这个?
更新
试过这个......
var options = {
host: "google.com"
};
同样的结果,所以我的代码中必定存在错误。有什么想法吗?
答案 0 :(得分:0)
最终成为代理问题......
var options = {
host: "proxy",
port: 80,
path: 'http://google.com'
};
注意主机中的代理。我将标记为this post
的副本