bug修复
This commit is contained in:
parent
44da94a71e
commit
67574732c7
|
@ -161,14 +161,14 @@ instance.interceptors.response.use(
|
||||||
console.log('接口error', error)
|
console.log('接口error', error)
|
||||||
if (loadingInstance) loadingInstance.close()
|
if (loadingInstance) loadingInstance.close()
|
||||||
|
|
||||||
const { response, message } = error
|
const { response, myMessage } = error
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
console.log('接口返回', response)
|
console.log('接口返回', response)
|
||||||
console.log('接口返回headers', response.headers)
|
console.log('接口返回headers', response.headers)
|
||||||
console.log('接口返回REDIRECT', response.headers.redirect)
|
console.log('接口返回REDIRECT', response.headers.redirect)
|
||||||
const { status, data } = response
|
const { status, data } = response
|
||||||
|
|
||||||
handleCode(status, data.msg || message, response.headers.redirect)
|
handleCode(status, data.msg || myMessage, response.headers.redirect)
|
||||||
if (response.headers.token) {
|
if (response.headers.token) {
|
||||||
setAccessToken(response.headers.token)
|
setAccessToken(response.headers.token)
|
||||||
}
|
}
|
||||||
|
@ -179,18 +179,18 @@ instance.interceptors.response.use(
|
||||||
|
|
||||||
return Promise.reject(error)
|
return Promise.reject(error)
|
||||||
} else {
|
} else {
|
||||||
let { message } = error
|
// let { message } = error
|
||||||
if (message === 'Network Error') {
|
if (error.message === 'Network Error') {
|
||||||
message = '后端接口连接异常'
|
error.message = '后端接口连接异常'
|
||||||
}
|
}
|
||||||
if (message.includes('timeout')) {
|
if (error.message.includes('timeout')) {
|
||||||
message = '后端接口请求超时'
|
error.message = '后端接口请求超时'
|
||||||
}
|
}
|
||||||
if (message.includes('Request failed with status code')) {
|
if (error.message.includes('Request failed with status code')) {
|
||||||
const code = message.substr(message.length - 3)
|
const code = error.message.substr(error.message.length - 3)
|
||||||
message = '后端接口' + code + '异常'
|
error.message = '后端接口' + code + '异常'
|
||||||
}
|
}
|
||||||
message.error(message || `后端接口未知异常`)
|
message.error(error.message || `后端接口未知异常`)
|
||||||
return Promise.reject(error)
|
return Promise.reject(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue