mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-01-23 09:40:25 +08:00
perf: improved exception handling when request status code is 200 (#4679)
This commit is contained in:
parent
6f3d50984f
commit
240f0b5f8d
@ -74,11 +74,13 @@ function createRequestClient(baseURL: string) {
|
||||
fulfilled: (response) => {
|
||||
const { data: responseData, status } = response;
|
||||
|
||||
const { code, data, message: msg } = responseData;
|
||||
const { code, data } = responseData;
|
||||
if (status >= 200 && status < 400 && code === 0) {
|
||||
return data;
|
||||
}
|
||||
throw new Error(`Error ${status}: ${msg}`);
|
||||
|
||||
const error = { response };
|
||||
throw error;
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -74,11 +74,12 @@ function createRequestClient(baseURL: string) {
|
||||
fulfilled: (response) => {
|
||||
const { data: responseData, status } = response;
|
||||
|
||||
const { code, data, message: msg } = responseData;
|
||||
const { code, data } = responseData;
|
||||
if (status >= 200 && status < 400 && code === 0) {
|
||||
return data;
|
||||
}
|
||||
throw new Error(`Error ${status}: ${msg}`);
|
||||
const error = { response };
|
||||
throw error;
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -73,11 +73,12 @@ function createRequestClient(baseURL: string) {
|
||||
fulfilled: (response) => {
|
||||
const { data: responseData, status } = response;
|
||||
|
||||
const { code, data, message: msg } = responseData;
|
||||
const { code, data } = responseData;
|
||||
if (status >= 200 && status < 400 && code === 0) {
|
||||
return data;
|
||||
}
|
||||
throw new Error(`Error ${status}: ${msg}`);
|
||||
const error = { response };
|
||||
throw error;
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -233,12 +233,13 @@ function createRequestClient(baseURL: string) {
|
||||
fulfilled: (response) => {
|
||||
const { data: responseData, status } = response;
|
||||
|
||||
const { code, data, message: msg } = responseData;
|
||||
const { code, data } = responseData;
|
||||
|
||||
if (status >= 200 && status < 400 && code === 0) {
|
||||
return data;
|
||||
}
|
||||
throw new Error(`Error ${status}: ${msg}`);
|
||||
const error = { response };
|
||||
throw error;
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -236,12 +236,13 @@ function createRequestClient(baseURL: string) {
|
||||
fulfilled: (response) => {
|
||||
const { data: responseData, status } = response;
|
||||
|
||||
const { code, data, message: msg } = responseData;
|
||||
const { code, data } = responseData;
|
||||
|
||||
if (status >= 200 && status < 400 && code === 0) {
|
||||
return data;
|
||||
}
|
||||
throw new Error(`Error ${status}: ${msg}`);
|
||||
const error = { response };
|
||||
throw error;
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -74,12 +74,13 @@ function createRequestClient(baseURL: string) {
|
||||
fulfilled: (response) => {
|
||||
const { data: responseData, status } = response;
|
||||
|
||||
const { code, data, message: msg } = responseData;
|
||||
const { code, data } = responseData;
|
||||
|
||||
if (status >= 200 && status < 400 && code === 0) {
|
||||
return data;
|
||||
}
|
||||
throw new Error(`Error ${status}: ${msg}`);
|
||||
const error = { response };
|
||||
throw error;
|
||||
},
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user