axios django 问题 not response status in interceptor.response

问题描述 投票:0回答:1
// 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);
    }
});

“网络错误”无任何反应 这是 CORS 及其设置方式的问题,因此 axios 从未从浏览器获取信息。你必须从服务器端解决它。

python django http-status-code-401
1个回答
1
投票

如果你有这个问题并使用 Django 添加到设置:

CORS_ALLOW_CREDENTIALS = True
© www.soinside.com 2019 - 2024. All rights reserved.