我正在尝试在我的节点服务器中进行http调用(我尝试的url是skackexchange公共url),下面是代码
httpsServer.js
var https = require('https');
function httpsRequest() {
var options = {
hostname: 'api.stackexchange.com',
path: '/2.2/answers',
method: 'GET'
};
var req = https.request(options, (res) => {
res.on('data', function (data) {
console.dir(data);
});
req.end();
});
req.on('error', function (e) {
console.error(e);
});
}
httpsRequest();然后我在我的控制台上做了node httpsServer
但是我得到了下面的错误。
Error:
{ Error: connect ECONNREFUSED xxx.xxx.xxx.xx:443
at Object.exports._errnoException (util.js:1050:11)
at exports._exceptionWithHostPort (util.js:1073:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1093:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: 'xxx.xxx.xxx.xx',
port: 443 }注意:我在代理服务器后面。
我做错了什么?如果是因为我在proxy后面,有没有办法让它工作?
https://stackoverflow.com/questions/44384325
复制相似问题