fix: problem that can't receive rejected message caused by interceptors; 🐛

修复:无法接受响应失败的消息;
This commit is contained in:
iczer 2020-08-27 15:36:46 +08:00
parent 2021fb575d
commit d1f84218c6

View File

@ -108,10 +108,10 @@ function loadInterceptors(interceptors, options) {
request.forEach(item => {
let {onFulfilled, onRejected} = item
if (!onFulfilled || typeof onFulfilled !== 'function') {
onFulfilled = () => {}
onFulfilled = config => config
}
if (!onRejected || typeof onRejected !== 'function') {
onRejected = () => {}
onRejected = error => Promise.reject(error)
}
axios.interceptors.request.use(
config => onFulfilled(config, options),
@ -122,10 +122,10 @@ function loadInterceptors(interceptors, options) {
response.forEach(item => {
let {onFulfilled, onRejected} = item
if (!onFulfilled || typeof onFulfilled !== 'function') {
onFulfilled = () => {}
onFulfilled = response => response
}
if (!onRejected || typeof onRejected !== 'function') {
onRejected = () => {}
onRejected = error => Promise.reject(error)
}
axios.interceptors.response.use(
response => onFulfilled(response, options),