From 1f25e8e096f737a05e4bac24caad78e6a5a79d77 Mon Sep 17 00:00:00 2001 From: Alex Grozav Date: Tue, 5 Nov 2024 13:02:55 +0200 Subject: [PATCH] fix(editor): Add optional chaining to error handler (no-changelog) (#11500) --- packages/editor-ui/src/utils/apiUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/editor-ui/src/utils/apiUtils.ts b/packages/editor-ui/src/utils/apiUtils.ts index fef135769e..8eb9f9548f 100644 --- a/packages/editor-ui/src/utils/apiUtils.ts +++ b/packages/editor-ui/src/utils/apiUtils.ts @@ -113,8 +113,8 @@ export async function request(config: { }); } - const errorResponseData = error.response.data; - if (errorResponseData !== undefined && errorResponseData.message !== undefined) { + const errorResponseData = error.response?.data; + if (errorResponseData?.message !== undefined) { if (errorResponseData.name === 'NodeApiError') { errorResponseData.httpStatusCode = error.response.status; throw errorResponseData;