我在文档步骤中找到了设置超时值的方法。
const instance = axios.create({
baseURL: 'https://some-domain.com/api/',
timeout: 1000,
headers: {'X-Custom-Header': 'foobar'}
});
Run Code Online (Sandbox Code Playgroud)
但是我在 axios 官方文档中找不到默认值 - https://github.com/axios/axios
默认超时时间是多少?
此外,在 AXIOS 下面使用 http 服务器/客户端(https://nodejs.org/api/http.html#http_class_http_clientrequest)
它是否使用 http 默认超时?我看到我的程序在 2 分钟后超时。
Chr*_*isG 29
根据自述文件,它是 0 表示没有超时
//
timeout指定请求超时前的毫秒数。// 如果请求时间超过
timeout,则请求将被中止。超时:1000,// 默认为
0(无超时)
https://github.com/axios/axios/blob/master/README.md#request-config
| 归档时间: |
|
| 查看次数: |
31512 次 |
| 最近记录: |