Search code examples
pythondjangohttp-status-code-401

Axios django problem not response status in interceptor.response


// Add a 401 response interceptor
window.axios.interceptors.response.use(function (response) {
    return response;
}, function (error) {
    if (401 === error.response.status) {
        // handle error: inform user, go to login, etc
    } else {
        return Promise.reject(error);
    }
});

"Network Error" without any response It was a problem with CORS and how it was setup, so axios never got the information back from the browser. You have to sort it out from the server side.


Solution

  • If you have this problem and use Django add to setings:

    CORS_ALLOW_CREDENTIALS = True