From 2ad1ad32b8410d84902a33d825032c282ca6df86 Mon Sep 17 00:00:00 2001 From: Soybean <2570172956@qq.com> Date: Tue, 30 Nov 2021 20:49:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(projects):=20=E8=AF=B7=E6=B1=82=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E7=BB=86=E8=8A=82=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/service/handler.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/utils/service/handler.ts b/src/utils/service/handler.ts index 2b4429cb..7d7f21a2 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; }