Axios GET 请求不起作用 [英] Axios GET request not working
本文介绍了Axios GET 请求不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用:Axios:0.17.1节点:8.0.0
I'm using: Axios: 0.17.1 Node: 8.0.0
以下标准 Node get 工作正常,但 Axios 版本不行.任何想法为什么?
The following standard Node get works fine, but the Axios version does not. Any ideas why?
节点http:
http
.get(`${someUrl}`, response => {
buildResponse(response).then(results => res.send(results));
})
.on('error', e => {
console.error(`Got error: ${e.message}`);
});
Axios:
axios
.get(`${someUrl}`)
.then(function(response) {
buildResponse(response).then(results => res.send(results));
})
.catch(function(error) {
handleError(error, res);
});
我刚收到一个 503,显示请求失败,状态码为 503"
I just get a 503 in the catch, with "Request failed with status code 503"
推荐答案
唯一对我有用的是取消设置代理:
The only thing that worked for me was unsetting the proxy:
delete process.env['http_proxy'];
delete process.env['HTTP_PROXY'];
delete process.env['https_proxy'];
delete process.env['HTTPS_PROXY'];
来自:使用axios时套接字挂断.get,但不是使用 https.get
这篇关于Axios GET 请求不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文