Axios GET请求不起作用

我正在使用:Axios:0.17.1节点:8.0.0

以下标准节点得到正常工作,但Axios版本没有。 任何想法为什么?

节点http:

http .get(`${someUrl}`, response => { buildResponse(response).then(results => res.send(results)); }) .on('error', e => { console.error(`Got error: ${e.message}`); }); 

爱可信:

 axios .get(`${someUrl}`) .then(function(response) { buildResponse(response).then(results => res.send(results)); }) .catch(function(error) { handleError(error, res); }); 

我只是得到一个503的捕获,“请求失败,状态码503”

看来你可以通过代理的细节Axios FYI。

从文档…

  // 'proxy' defines the hostname and port of the proxy server // Use `false` to disable proxies, ignoring environment variables. // `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and // supplies credentials. // This will set an `Proxy-Authorization` header, overwriting any existing // `Proxy-Authorization` custom headers you have set using `headers`. proxy: { host: '127.0.0.1', port: 9000, auth: { username: 'mikeymike', password: 'rapunz3l' } }, 

唯一对我有用的是取消了代理服务器的设置:

 delete process.env['http_proxy']; delete process.env['HTTP_PROXY']; delete process.env['https_proxy']; delete process.env['HTTPS_PROXY']; 

From: 使用axios.get时,套接字会挂起,但使用https.get时不会挂起