fix(projects): fix request msg
This commit is contained in:
parent
6ea9b85ff1
commit
ae6b6134f3
@ -61,8 +61,8 @@ function createCommonRequest<ResponseData = any>(
|
|||||||
'the backend request error',
|
'the backend request error',
|
||||||
BACKEND_ERROR_CODE,
|
BACKEND_ERROR_CODE,
|
||||||
response.config,
|
response.config,
|
||||||
response,
|
response.request,
|
||||||
response.request
|
response
|
||||||
);
|
);
|
||||||
|
|
||||||
await opts.onError(backendError);
|
await opts.onError(backendError);
|
||||||
|
@ -30,7 +30,7 @@ export const request = createFlatRequest<App.Service.Response>(
|
|||||||
return response.data.code === '0000';
|
return response.data.code === '0000';
|
||||||
},
|
},
|
||||||
async onBackendFail(_response) {
|
async onBackendFail(_response) {
|
||||||
// when the backend response code is not 200, it means the request is fail
|
// when the backend response code is not "0000", it means the request is fail
|
||||||
// for example: the token is expired, refetch token and retry request
|
// for example: the token is expired, refetch token and retry request
|
||||||
},
|
},
|
||||||
transformBackendResponse(response) {
|
transformBackendResponse(response) {
|
||||||
@ -43,7 +43,7 @@ export const request = createFlatRequest<App.Service.Response>(
|
|||||||
|
|
||||||
// show backend error message
|
// show backend error message
|
||||||
if (error.code === BACKEND_ERROR_CODE) {
|
if (error.code === BACKEND_ERROR_CODE) {
|
||||||
message = error.request?.data.msg || message;
|
message = error.response?.data?.msg || message;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.$message?.error(message);
|
window.$message?.error(message);
|
||||||
@ -67,12 +67,12 @@ export const demoRequest = createRequest<App.Service.DemoResponse>(
|
|||||||
return config;
|
return config;
|
||||||
},
|
},
|
||||||
isBackendSuccess(response) {
|
isBackendSuccess(response) {
|
||||||
// when the backend response code is 200, it means the request is success
|
// when the backend response code is "200", it means the request is success
|
||||||
// you can change this logic by yourself
|
// you can change this logic by yourself
|
||||||
return response.data.status === '200';
|
return response.data.status === '200';
|
||||||
},
|
},
|
||||||
async onBackendFail(_response) {
|
async onBackendFail(_response) {
|
||||||
// when the backend response code is not 200, it means the request is fail
|
// when the backend response code is not "200", it means the request is fail
|
||||||
// for example: the token is expired, refetch token and retry request
|
// for example: the token is expired, refetch token and retry request
|
||||||
},
|
},
|
||||||
transformBackendResponse(response) {
|
transformBackendResponse(response) {
|
||||||
@ -85,7 +85,7 @@ export const demoRequest = createRequest<App.Service.DemoResponse>(
|
|||||||
|
|
||||||
// show backend error message
|
// show backend error message
|
||||||
if (error.code === BACKEND_ERROR_CODE) {
|
if (error.code === BACKEND_ERROR_CODE) {
|
||||||
message = error.request?.data.message || message;
|
message = error.response?.data?.message || message;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.$message?.error(message);
|
window.$message?.error(message);
|
||||||
|
Loading…
Reference in New Issue
Block a user