fix: 修复请求响应不报错问题
This commit is contained in:
@@ -50,8 +50,11 @@ function createCommonRequest<ResponseData = any>(
|
|||||||
async response => {
|
async response => {
|
||||||
// 对仪表盘接口做特殊处理
|
// 对仪表盘接口做特殊处理
|
||||||
if (response.config.url?.includes('/u/account/dashboard')) {
|
if (response.config.url?.includes('/u/account/dashboard')) {
|
||||||
|
// 如果响应中包含数据但没有明确的错误信息,也视为成功
|
||||||
|
if (response.data && !response.data.error) {
|
||||||
return Promise.resolve(response);
|
return Promise.resolve(response);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (opts.isBackendSuccess(response)) {
|
if (opts.isBackendSuccess(response)) {
|
||||||
return Promise.resolve(response);
|
return Promise.resolve(response);
|
||||||
@@ -62,11 +65,6 @@ function createCommonRequest<ResponseData = any>(
|
|||||||
return fail;
|
return fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果响应中包含数据但没有明确的错误信息,也视为成功
|
|
||||||
if (response.data && !response.data.error) {
|
|
||||||
return Promise.resolve(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
const backendError = new AxiosError<ResponseData>(
|
const backendError = new AxiosError<ResponseData>(
|
||||||
'the backend request error',
|
'the backend request error',
|
||||||
BACKEND_ERROR_CODE,
|
BACKEND_ERROR_CODE,
|
||||||
|
|||||||
Reference in New Issue
Block a user