I am getting this error on console: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'message') at eval. This is my code in axios.js:
axiosIns.interceptors.response.use(
response => {
if (response.message === 'Unauthenticated') {
window.location = '/login'
}
return response
},
error => {
if (error.response.message === 'Unauthenticated') {
window.location = '/login'
} else if (error.response.status === 401) {
removeUserData()
return Promise.reject(error)
}
})
CodePudding user response:
Try to replace response.message
and error.response.message
by response.statusText
and error.response.statusText
.