Skip to content

Commit ae6b613

Browse files
committed
fix(projects): fix request msg
1 parent 6ea9b85 commit ae6b613

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

packages/axios/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ function createCommonRequest<ResponseData = any>(
6161
'the backend request error',
6262
BACKEND_ERROR_CODE,
6363
response.config,
64-
response,
65-
response.request
64+
response.request,
65+
response
6666
);
6767

6868
await opts.onError(backendError);

src/service/request/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const request = createFlatRequest<App.Service.Response>(
3030
return response.data.code === '0000';
3131
},
3232
async onBackendFail(_response) {
33-
// when the backend response code is not 200, it means the request is fail
33+
// when the backend response code is not "0000", it means the request is fail
3434
// for example: the token is expired, refetch token and retry request
3535
},
3636
transformBackendResponse(response) {
@@ -43,7 +43,7 @@ export const request = createFlatRequest<App.Service.Response>(
4343

4444
// show backend error message
4545
if (error.code === BACKEND_ERROR_CODE) {
46-
message = error.request?.data.msg || message;
46+
message = error.response?.data?.msg || message;
4747
}
4848

4949
window.$message?.error(message);
@@ -67,12 +67,12 @@ export const demoRequest = createRequest<App.Service.DemoResponse>(
6767
return config;
6868
},
6969
isBackendSuccess(response) {
70-
// when the backend response code is 200, it means the request is success
70+
// when the backend response code is "200", it means the request is success
7171
// you can change this logic by yourself
7272
return response.data.status === '200';
7373
},
7474
async onBackendFail(_response) {
75-
// when the backend response code is not 200, it means the request is fail
75+
// when the backend response code is not "200", it means the request is fail
7676
// for example: the token is expired, refetch token and retry request
7777
},
7878
transformBackendResponse(response) {
@@ -85,7 +85,7 @@ export const demoRequest = createRequest<App.Service.DemoResponse>(
8585

8686
// show backend error message
8787
if (error.code === BACKEND_ERROR_CODE) {
88-
message = error.request?.data.message || message;
88+
message = error.response?.data?.message || message;
8989
}
9090

9191
window.$message?.error(message);

0 commit comments

Comments
 (0)