1.第一次请求interceptors中请求头能看到token/authorization
2.但是第二次请求就失效了,请求头看不到token/authorization
解决:
axios.interceptors.request.use(config => {
config.headers = {
authorization: token,
...config.headers
}
return config;
}
)
const data = await axios.get(`${getTagsByTheme}?themeId=${themeId}`, {
headers: {
authorization: token
}
});
再axios.get中加入headers: {
authorization:token
}