美文网首页
RN Fetch处理时间超时

RN Fetch处理时间超时

作者: 亦晴工作室 | 来源:发表于2017-08-18 09:01 被阅读187次

1、打开目录 /xxxx/node_modules/whatwg-fetch/fetch.js

2、
我们加上一段给xhr对象的timeout属性赋值的代码:
//我们只需要加上下面这段代码即可
if(init!=null&&init.timeout!=null){
      xhr.timeout=init.timeout;
}

然后在我们调用的时候,我们就可以开心的传递我们的timeout参数了:

let response = await fetch(url, {
              headers: this.method == 'GET' ? null : this.headers,
              method: this.method,
              body: this.method == 'GET' ? null : this.body,
              timeout:10000
});

相关文章

网友评论

      本文标题:RN Fetch处理时间超时

      本文链接:https://www.haomeiwen.com/subject/ltmorxtx.html