码迷,mamicode.com
首页 > 移动开发 > 详细

Vue+axios 拦截,超时登录问题

时间:2019-07-01 17:24:07      阅读:285      评论:0      收藏:0      [点我收藏+]

标签:ios   ror   const   ESS   return   session   div   href   axios   

axios.interceptors.request.use(config => config, error => Promise.reject(error));

axios.interceptors.response.use((response) => {
  const status = response.data.statusCode;
  if (status === ‘AAM-ER-301‘ || status === ‘AAM-ER-302‘ || status === ‘AAM-ER-303‘) {
    alert(‘已超时,请重新登录‘);
    if (sessionStorage.getItem(‘isNaigation‘) === ‘yes‘) {
      window.parent.location.href = ‘/‘;
    } else {
      window.location.href = ‘/‘;
    }
  } else return response;
}, error => Promise.reject(error));

参考: https://blog.csdn.net/H1069495874/article/details/80057107  

Vue+axios 拦截,超时登录问题

标签:ios   ror   const   ESS   return   session   div   href   axios   

原文地址:https://www.cnblogs.com/arealy/p/11115020.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!