书法字典:https://www.shufadict.com

Axios 禁用缓存

Disable cache for Axios
1. set headers.Cache-Control = 'no cache' // not work for 0.19.x or later?
2. set timestamp in url parameter for each request(need backend work)

export const client = axios.create({
    baseURL: 'https://www.abc.com/api',
    timeout: 10000,
});

client.interceptors.request.use(
    config => {
        config.params = {...config.params, timestamp: Date.now()};
        config.headers.Authorize = localStorage.getItem('token') || '';
        return config
    },
    error => Promise.reject(error)
);

 

作者:zdd
出处:http://www.cnblogs.com/graphics/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.

posted on 2020-08-12 17:06  翰墨小生  阅读(2245)  评论(0编辑  收藏  举报

导航

书法字典:https://www.shufadict.com