【发布时间】:2018-11-12 04:54:06
【问题描述】:
我的 fetch API 总是返回旧的 json 数据。我的应用程序为我的用户列表请求 API,它在开始时工作,但是当我发布新用户并刷新我的列表(调用相同的 fetch 函数)时,它返回了相同的列表(没有新用户)。但只要我完全关闭我的应用程序并重新打开它,它就会起作用。我想知道为什么会发生这种情况。我需要“重置”我的 fetch API 函数吗?有这样的功能吗?
这是我的获取函数:
fetch(GET_USER_SESSION, {
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
})
.then((response) => response.json())
.then((data) => {
return data // return same old list
}).catch((err) => this.showError('Error Signing Up, Please Try Again.'));
有什么想法吗?非常感谢!
【问题讨论】:
-
你找到解决办法了吗?
标签: android react-native fetch-api