[英]Why Axios is timing out even when the request is tested in postman?
I am trying to configure one request for my app using axios with express/node js.我正在尝试使用 axios 和 express/node js 为我的应用程序配置一个请求。
Below is the code snippet generated with postman app, ofc before i have tried several variations with creating my own form etc, always same ending.下面是使用 postman 应用程序生成的代码片段,在我尝试创建自己的表单等的几种变体之前,总是相同的结尾。
const express = require('express')
const axios = require('axios')
var qs = require('qs');
var data = qs.stringify({
'grant_type': 'client_credentials',
'client_id': 'myclientid',
'client_secret': 'myclientsecret',
'scope': 'myscope'
});
var config = {
method: 'post',
url: 'https://myurl/token',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
I am always receiving those errors:我总是收到这些错误:
Error: connect ETIMEDOUT IPADDRESS:443
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1128:14) {
errno: 'ETIMEDOUT',
code: 'ETIMEDOUT',
syscall: 'connect',
address: 'IPA ADDRESS',
port: 443,
Same code snippet is working correctly in Postman and I am receiving token so I am not sure where I am doing the mistake.相同的代码片段在 Postman 中正常工作,我正在接收令牌,所以我不确定我在哪里做错了。
Anyone?任何人?
Thanks!谢谢!
Ok, I figured it out.好的,我想通了。 This problem was caused by proxy settings in my company, had to use proxy agent for axios to resolve address properly.
这个问题是我公司的代理设置引起的,必须使用axios的代理才能正确解析地址。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.