axios.interceptors.request.use((config) => {
// Set the AUTH token for any request
const token = window.localStorage.getItem('token');
if (token) {
config.headers.Authorization = token;
}
return config;
});
参考链接:https://stackoverflow.com/questions/43051291/attach-authorization-header-for-all-axios-requests