Vue+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  

猜你喜欢

转载自www.cnblogs.com/arealy/p/11115020.html