我的django登录授权未通过返回错误代码401或400来通过。我不想打印它,我想抓住它。
axios.interceptors.response.use(
undefined,
err => {
let res = err.response;
switch (res.status){
case 401:
store.state.username = '';
store.state.token = '';
store.state.isLogin = false;
localStorage.removeItem('token'); // 清除相关storage
localStorage.removeItem('name'); // 清除相关storage
router.replace({
path: '/login',
query: {redirect: router.currentRoute.fullPath}
})
}
return Promise.reject(err);
}
我不想在控制台输出中看到错误enter image description here