我正在使用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默认超时
发布评论