Commit 9ebf1fe1 authored by lipengcheng 's avatar lipengcheng

test

parent d11265df
......@@ -2,7 +2,7 @@
// 如果设置了全局拦截器,想取消实例中发出的请求,必须先移除全局拦截器,实例中配置的config.cancelToken属性才会生效
import axios from 'axios'
import handleStatus from '@/plugins/axios/axios.handleStatus.js'
// import handleStatus from '@/plugins/axios/axios.handleStatus.js'
import setOptions from '@/plugins/axios/axios.setOptions.js'
// import store from '@/store/index'
// import router from '@/router/index.js'
......@@ -51,13 +51,19 @@ const responseInterceptors = request.interceptors.response.use(
(response) => {
const { config } = response
pendingPool.delete(config.url)
return Promise.resolve(handleStatus(response))
if (response.status === 200) {
return Promise.resolve(response)
} else {
return Promise.reject(response)
}
// return Promise.resolve(handleStatus(response))
},
// 对响应错误做点什么
(err) => {
console.log('响应拦截err:', err)
console.log('pendingPool2:', pendingPool)
console.log('axios.isCancel(err):', axios.isCancel(err))
console.log('err.response.status:', err.response.status)
// 错误信息err传入isCancel方法,可以判断请求是否被取消
if (axios.isCancel(err)) {
throw new axios.Cancel(err.message || '请求被主动取消')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment