fix: request error handler 处理

This commit is contained in:
winixt 2021-05-10 20:42:29 +08:00
parent 3357d71caf
commit eb2bb5a014
3 changed files with 7 additions and 8 deletions

View File

@ -12,10 +12,10 @@ function handleAbnormalCode(errorHandler = {}, code, response) {
}
function handleRequestError(errorHandler = {}, error) {
if (error.type) {
errorHandler[error.type] && errorHandler[error.type](error);
} else if (error.response) {
errorHandler[error.response.status] && errorHandler[error.response.status](error);
if (error.type && errorHandler[error.type]) {
errorHandler[error.type](error);
} else if (error.response && errorHandler[error.response.status]) {
errorHandler[error.response.status](error);
} else if (errorHandler.default) {
errorHandler.default(error);
}

View File

@ -13,10 +13,11 @@ export const request = {
111(responseData) {
console.log(responseData);
},
404() {
console.log('to 404 page');
500() {
console.log('500 error');
},
default(error) {
console.log('default error');
console.log(error);
}
}

View File

@ -30,8 +30,6 @@ export default {
dataField: false
}).then((res) => {
console.log(res);
}).catch((err) => {
console.error(err);
});
return {
fes,