From 15bee13e234b9b2dcc300bbadff1a4bb4d263461 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D0=B0=D1=81=D1=83=D0=BB?= Date: Mon, 26 Feb 2024 20:35:38 +0300 Subject: [PATCH] feat: fix error condition --- src/components/AddItemModal/index.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/AddItemModal/index.tsx b/src/components/AddItemModal/index.tsx index 19f560e70..1410e4972 100644 --- a/src/components/AddItemModal/index.tsx +++ b/src/components/AddItemModal/index.tsx @@ -72,8 +72,10 @@ const handleSubmitForm = async ( } catch (err: any) { let errorMessage = NODE_ADD_ERROR - if (err?.response && err.response.data && err.response.data.message) { - errorMessage = err.response.data.message + if (err.status === 400) { + const error = await err.json() + + errorMessage = error.errorCode || error?.status || NODE_ADD_ERROR } else if (err instanceof Error) { errorMessage = err.message }