From bff49bc8ce79df8787b211abc2f4e8e49db19851 Mon Sep 17 00:00:00 2001 From: vhande <78013271+vhande@users.noreply.github.com> Date: Fri, 22 Nov 2024 10:49:55 +0100 Subject: [PATCH] Implement handleErrorObject --- src/hooks/api/organizers.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/hooks/api/organizers.ts b/src/hooks/api/organizers.ts index b4d510702..bd0e2c2ce 100644 --- a/src/hooks/api/organizers.ts +++ b/src/hooks/api/organizers.ts @@ -16,6 +16,7 @@ import { fetchFromApi, isErrorObject } from '@/utils/fetchFromApi'; import type { Headers } from './types/Headers'; import type { User } from './user'; +import { handleErrorObject } from '@/utils/handleErrorObject'; type HeadersAndQueryData = { headers: Headers; @@ -173,17 +174,11 @@ type UseGetOrganizerPermissionsArguments = ServerSideQueryOptions & { const getOrganizerPermissions = async ({ headers, organizerId }) => { const res = await fetchFromApi({ path: `/organizers/${organizerId}/permissions`, - options: { - headers, - }, + options: { headers }, }); - if (isErrorObject(res)) { - // eslint-disable-next-line no-console - return console.error(res); - } - return await res.json(); -}; + return handleErrorObject(res); +}; const useGetOrganizerPermissions = ( { req, queryClient, organizerId }: UseGetOrganizerPermissionsArguments, configuration: UseQueryOptions = {},