标签:inter class 处理 turn span out 返回 错误 col
/** * http响应拦截器 */ import axios from ‘axios‘ import { Toast, Indicator } from ‘mint-ui‘ //Toast提示 import router from ‘../router‘ //路由 ///request拦截器 axios.interceptors.request.use(req => { //向请求头添加token let token = localStorage.getItem(‘token‘) if (token) { req.headers.Authorization = ‘Bearer ‘ + token } return req; }, error => { return Promise.reject(error); }) //response拦截器 axios.interceptors.response.use(res => { return res; }, error => { //token失效返回401处理 if (error.response.code == 401) { //刷新token } return Promise.reject(error.response.data) // 返回错误信息 })
标签:inter class 处理 turn span out 返回 错误 col
原文地址:https://www.cnblogs.com/223zzm/p/11747148.html