因此,我的Vue应用程序存在问题,axios intercept没有应用授权令牌.
axios.interceptors.request.use(config => {
let token = localStorage.getItem("jwt_token")
console.log("Token is: ", token)
console.log(typeof token)
if (token) {
axios.defaults.headers.Authorization = `Bearer ${token}`
}
console.log(config)
return config
});
正如您所见,在将令牌应用到Auth头之前,我已经在控制台上记录了令牌,然而这是我在控制台日志(log)中得到的.
on the second API request, my token applies just fine, and I receive data back.