📜  自动刷新令牌(回调) - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:32.391000             🧑  作者: Mango

代码示例2
Axios.interceptors.response.use(response => response, error => {
    const status = error.response ? error.response.status : null

    if (status === 401) {

        return refreshToken(store, _ => {
            error.config.headers['Authorization'] = 'Bearer ' + store.state.auth.token;
            error.config.baseURL = undefined;
            return Axios.request(error.config);
        });
    }

    return Promise.reject(error);
});