什么是Axios默认超时 [英] What is Axios default timeout

查看:795
本文介绍了什么是Axios默认超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现在文档设置步骤中设置了超时值.

I found in the documentation steps to set the timeout value.

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

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

But I could not find the default value in the official axios documentation - https://github.com/axios/axios

默认超时是多少?

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

Also, Underneath AXIOS uses http server/client (https://nodejs.org/api/http.html#http_class_http_clientrequest)

它使用http默认超时吗? 2分钟后我看到程序超时.

Does it use the http default timeout? I see my program timesout after 2 minutes.

推荐答案

根据自述文件,该值为0表示没有超时

According to the README, it is 0 which means no timeout

//timeout指定请求超时之前的毫秒数.

// timeout specifies the number of milliseconds before the request times out.

//如果请求花费的时间长于timeout,则该请求将被中止. 超时:1000,

// If the request takes longer than timeout, the request will be aborted. timeout: 1000,

//默认为0(无超时)

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

这篇关于什么是Axios默认超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆