From 3ab5b0d86bd0cb2ae5f41d6e61ba0efdb2ef68b5 Mon Sep 17 00:00:00 2001 From: whyour Date: Wed, 29 Jan 2025 23:50:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E6=B2=A1=E6=9C=89=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/http.tsx | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/utils/http.tsx b/src/utils/http.tsx index af604fb4..785c6905 100644 --- a/src/utils/http.tsx +++ b/src/utils/http.tsx @@ -57,18 +57,19 @@ const errorHandler = function ( return error.config?.onError(error.response); } - notification.error({ - message: msg, - description: ( - <> - {error.response?.data?.errors?.map((item: any) => ( -
- {item.message} ({item.value}) -
- ))} - - ), - }); + msg && + notification.error({ + message: msg, + description: error.response?.data?.errors ? ( + <> + {error.response?.data?.errors?.map((item: any) => ( +
+ {item.message} ({item.value}) +
+ ))} + + ) : undefined, + }); } } else { console.log(error.message); @@ -117,13 +118,13 @@ _request.interceptors.response.use(async (response) => { msg && notification.error({ message: msg, - description: ( + description: res?.errors ? ( <> {res?.errors.map((item: any) => (
{item.message}
))} - ), + ) : undefined, }); } return res;