1.可能单词写错了
axios.interceptors.request.use(请求拦截器)
axios.interceptors.response.use(响应拦截器)
2.是因为在添加请求拦截器的时候,最后没有添加返回值return config方法
正确的写法应该是:
axios.interceptors.request.use((config)=>{undefined
if(getStore(‘token’)){undefined
config.headers.Authorization=getStore(‘token’);
}
return config;
},(error)=>{undefined
console.log(error);
});