javascript - How does axios handle errors of the same type uniformly?
巴扎黑
巴扎黑 2017-05-19 10:10:54
0
1
517
// 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?

巴扎黑
巴扎黑

reply all(1)
曾经蜡笔没有小新

Business logic should be in then(), right?
err handles errors

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!