现在有一个大概需要6分钟才返回结果的接口,查看axios官方文档默认是1000毫秒,于是我改成了30分钟:
const http = axios.create({
timeout: 30 * 60 * 1000,
headers: {
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest'
}
})
但是在请求接口的时候,2分钟或者4分钟就断开了:
通过查资料才发现,是谷歌浏览器有默认设置时长的,大概 4分钟超时,xhr 2分钟超时。
- chrome 72.x 为4min
- safari 12 为8min
- firefox 65 貌似没有超时时间
因此在vue中config文件中index.js,配置timeout即可:
proxyTable:{
/xxx:{
timeout: 30*60*1000,
}
}