什么是 Axios 默认超时

  • 本文关键字:默认 超时 Axios axios
  • 更新时间 :
  • 英文 :


我在文档步骤中找到了设置超时值的步骤。

const instance = axios.create({
baseURL: 'https://some-domain.com/api/',
timeout: 1000,
headers: {'X-Custom-Header': 'foobar'}
});

但是我在官方 axios 文档中找不到默认值 - https://github.com/axios/axios

默认超时是多少?

此外,Underneath AXIOS使用http服务器/客户端(https://nodejs.org/api/http.html#http_class_http_clientrequest(

它是否使用 http 默认超时? 我看到我的程序在 2 分钟后超时。

根据自述文件,它是 0,这意味着没有超时

// `timeout` specifies the number of milliseconds before the request times out.
// If the request takes longer than `timeout`, the request will be aborted.
timeout: 1000, // default is `0` (no timeout)

https://github.com/axios/axios/blob/master/README.md#request-config

最新更新