【发布时间】:2020-07-28 03:51:12
【问题描述】:
我在我的 React-Native 应用程序中使用 axios
首先,配置标题
function configHeaders()
{
// I tested all these below 3 lines , no on worked
axios.defaults.headers.common["Pragma"] = "no-cache";
axios.defaults.headers.common["Cache-Control"] = "no-cache";
axios.defaults.headers.common["Cache-Control"] = "no-store";
}
以下请求返回的数据是旧数据,不是我数据库中的当前数据
exports.getInfo = async function ()
{
configHeaders();
return await cachios.get(URL + '/user/info').then(data => {
return { success : true , data : data.data.data.user };
}).catch(err => {
return { success : false , message : err.response.data.message };
});
}
【问题讨论】:
-
你在 axios 设置中试过 'Cache-Control': 'no-cache' 吗?
-
也可以通过stackoverflow.com/questions/49263559/…链接查看ans
标签: javascript node.js ajax react-native axios