From 7db181a2917ce782bc771d46299dad33003f21d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Suwi=C5=84ski?= Date: Tue, 28 May 2024 11:55:03 +0200 Subject: [PATCH] cover react-admin undefined meta param (#556) --- src/hydra/dataProvider.test.ts | 1 + src/hydra/dataProvider.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hydra/dataProvider.test.ts b/src/hydra/dataProvider.test.ts index 287e5d75..d081010a 100644 --- a/src/hydra/dataProvider.test.ts +++ b/src/hydra/dataProvider.test.ts @@ -333,6 +333,7 @@ describe('Transform a React Admin request to an Hydra request', () => { previousData: { id: '/entrypoint/resource/1', }, + meta: undefined, }); const url = mockFetchHydra.mock.calls?.[0]?.[0] ?? new URL('https://foo'); expect(url).toBeInstanceOf(URL); diff --git a/src/hydra/dataProvider.ts b/src/hydra/dataProvider.ts index a721b534..1d09f69e 100644 --- a/src/hydra/dataProvider.ts +++ b/src/hydra/dataProvider.ts @@ -351,10 +351,10 @@ function dataProvider( } }); let extraInformation: { hasFileField?: boolean } = {}; - if ('meta' in params) { + if (typeof params.meta === 'object') { extraInformation = params.meta; } - const updateHttpMethod = extraInformation?.hasFileField ? 'POST' : 'PUT'; + const updateHttpMethod = extraInformation.hasFileField ? 'POST' : 'PUT'; switch (type) { case CREATE: