// interceptors
axios.interceptors.response.use(function (response) {
return response;
}, function (error) {
// 处理统一的验证失效错误.
return Promise.reject(error);
});
// 页面中
axios.post('/user', {
firstName: 'Fred',
lastName: 'Flintstone'
})
.then(function (response) {
console.log(response);
}, function (err) {
// 在此处处理特定业务错误:
console.log(err.msg)
// 问题是: 当我在拦截器里处理了验证失效后, 它还是会执行到这里面
})
My question is: After I handle the validation error in the interceptor, how do I prevent the separate business processing in the page from executing?
Business logic should be in then(), right?
err handles errors