The api give 401 Unauthorized error because of expired token.
Even though, error status code(401) is not available in axios interceptor.
Vue.axios.interceptors.response.use(function(response) {
return response;
}, function(error) {
// I want to catch the 401 error here but, error.response is undefined
return Promise.reject(error);
});
Is there any way i can get it, the below github issue says error.response.status can be used, but error.response is undefined for me.
Http Error: Failed to load http://localhost:5000/api/user: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:2323' is therefore not allowed access. The response had HTTP status code 401.
Console.log(error) from intercepter response.use Error: Network Error at createError (createError.js:16) at XMLHttpRequest.handleError (xhr.js:87)
Access-Control-Allow-Origin
option – samayo