修复:更正 axios 拦截器demo;

master
chenghongxing 4 years ago
parent 5de611523c
commit 34a76d5894
  1. 21
      src/utils/axios-interceptors.js

@ -9,8 +9,8 @@ const resp401 = {
*/
onFulfilled(response, options) {
const {message} = options
if (response.status === 401) {
message.error('无此接口权限')
if (response.code === 401) {
message.error('无此权限')
}
return response
},
@ -22,7 +22,10 @@ const resp401 = {
*/
onRejected(error, options) {
const {message} = options
message.error(error.message)
const {response} = error
if (response.status === 401) {
message.error('无此权限')
}
return Promise.reject(error)
}
}
@ -30,10 +33,18 @@ const resp401 = {
const resp403 = {
onFulfilled(response, options) {
const {message} = options
if (response.status === 403) {
message.error(`请求被拒绝`)
if (response.code === 403) {
message.error('请求被拒绝')
}
return response
},
onRejected(error, options) {
const {message} = options
const {response} = error
if (response.status === 403) {
message.error('请求被拒绝')
}
return Promise.reject(error)
}
}

Loading…
Cancel
Save