Skip to content

Commit

Permalink
fix(projects): 请求相关细节修复
Browse files Browse the repository at this point in the history
  • Loading branch information
Soybean committed Nov 30, 2021
1 parent ff9216b commit 2ad1ad3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/utils/service/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ export function requestMiddleware<MiddlewareData>(
) {
const errorIndex = requests.findIndex(item => item.error !== null);
const hasError = errorIndex > -1;
if (hasError) {
const failResult: CustomFailRequestResult = {
data: null,
error: requests[errorIndex].error!
};
return failResult;
}
const successResult: CustomSuccessRequestResult<MiddlewareData> = {
data: resultHandler(...requests.map(item => item.data)),
error: null
};
const failResult: CustomFailRequestResult = {
data: null,
error: requests[errorIndex].error!
};
return hasError ? failResult : successResult;
return successResult;
}

1 comment on commit 2ad1ad3

@vercel
Copy link

@vercel vercel bot commented on 2ad1ad3 Nov 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.