I get this error on the console: Uncaught (in promise) TypeError: Cannot read property of undefined at eval (read 'message'). 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) } })
P粉3453027532024-03-28 11:31:44
Try replacing response.message
and error.response.message
with response.statusText
and error.response.statusText
.