删除提取API默认超时 [英] Removing Fetch API default timeout

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

问题描述

我正在使用Google Chrome或Mozilla Firefox的本机访存向服务器发送查询:

I'm sending queries to my server using native fetch from Google Chrome or Mozilla Firefox:

fetch(url, {
  method: 'POST',
  body: formData,
  credentials: 'include'
})

我将服务器设置为在3分钟后发送响应,并意识到两种浏览器仅等待2分钟. Firefox在失败之前再次重新发送请求.

I set up a server to send a response after 3 minutes and realized that both browsers only wait 2 minutes. Firefox resend the request once more before failing.

是否可以定义大于2分钟的超时时间(例如无限)?

Is there a way to define a timeout bigger than 2 minutes (say infinite)?

推荐答案

据我阅读的有关MDN的fetch()文档,它没有任何指定超时的方法.

As far as I read fetch()'s documentation on MDN, it does not have any way to specify a timeout.

如果使用的是nodejs,则可以使用请求 axios 模块. 或者您可以使用 XMLHttpRequest (浏览器中的纯JavaScript).

You can use request or axios module if you are using nodejs. or you can use XMLHttpRequest (plain javascript in browser).

有关详细信息,请参见 JavaScript中的HTTP请求超时

For more information HTTP request timeouts in JavaScript

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

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