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) } })
Try replacing
response.message
anderror.response.message
withresponse.statusText
anderror.response.statusText
.