我正在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 im呼叫如下:
loadContent(userid){
let url = `http://####.com/api/loadContent?User_id=${userid}`;
return fetch(url).then((response) => response.json());
}