在手机端的chrome浏览器中,fetch发送的Post请求,他的超时时间是多少?如何能延长这个手机端的默认超时时间?

想问的是手机端的chrome浏览器的超时时间。

用的是 fetch的post请求。

因为前端在PC端是可以完成对应连接的,时长大概是4分钟多一点。
而今天在手机端,使用没有超过140秒就报错了,具体没有分析,目前感觉可能是手机端的默认超时时间问题。
前几天看过文章,好像是手机端,短一些。

阅读 3k
1 个回答
const TIMEOUT = 5000; // 设置超时时间为5秒

const controller = new AbortController();
const { signal } = controller;

const fetchWithTimeout = fetch(url, { signal });

setTimeout(() => controller.abort(), TIMEOUT);

fetchWithTimeout.then(response => {
  // 处理响应
}).catch(error => {
  if (error.name === 'AbortError') {
    // 处理超时
  } else {
    // 处理其他错误
  }
});
推荐问题