diff --git a/src/utils/service/handler.ts b/src/utils/service/handler.ts index 2b4429cbc..7d7f21a21 100644 --- a/src/utils/service/handler.ts +++ b/src/utils/service/handler.ts @@ -12,13 +12,16 @@ export function requestMiddleware( ) { 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 = { data: resultHandler(...requests.map(item => item.data)), error: null }; - const failResult: CustomFailRequestResult = { - data: null, - error: requests[errorIndex].error! - }; - return hasError ? failResult : successResult; + return successResult; }