React Native - 获取调用缓存
P粉585541766
P粉585541766 2023-10-21 23:44:23
0
2
479

我正在用 React Native 构建一个应用程序,它进行依赖于服务器的最新信息的获取调用。我注意到它似乎缓存了响应,如果我再次运行该 fetch 调用,它会返回缓存的响应,而不是来自服务器的新信息。

我的功能如下:

goToAll() {
  AsyncStorage.getItem('FBId')
    .then((value) => {
      api.loadCurrentUser(value)
        .then((res) => {
          api.loadContent(res['RegisteredUser']['id'])
            .then((res2) => {
              console.log(res2);
              this.props.navigator.push({
                component: ContentList,
                title: 'All',
                passProps: {
              content: res2,
            user: res['RegisteredUser']['id']
          }
        })
      });
    });
  })
  .catch((error) => {console.log(error);})
  .done();
}

我调用的 api.js 函数如下:

loadContent(userid){
  let url = `http://####.com/api/loadContent?User_id=${userid}`;
  return fetch(url).then((response) => response.json());
}


P粉585541766
P粉585541766

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!