From d821b1ead17721c93f7a243979a889391fcca5c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gast=C3=B3n=20Fournier?= Date: Fri, 27 Jan 2023 11:18:32 +0100 Subject: [PATCH] fix: missing formatApiPath (#3006) ## About the changes Archive page is not loading archived feature toggles. When fetching from the server is not including the baseUrl --- .../src/hooks/api/getters/useFeatures/useFeatures.ts | 3 ++- .../api/getters/useFeaturesArchive/useFeaturesArchive.ts | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/hooks/api/getters/useFeatures/useFeatures.ts b/frontend/src/hooks/api/getters/useFeatures/useFeatures.ts index 056b0b94a2..3566d5d0d4 100644 --- a/frontend/src/hooks/api/getters/useFeatures/useFeatures.ts +++ b/frontend/src/hooks/api/getters/useFeatures/useFeatures.ts @@ -1,5 +1,6 @@ import { FeaturesSchema } from 'openapi'; import useSWR from 'swr'; +import { formatApiPath } from 'utils/formatPath'; import handleErrorResponses from '../httpErrorResponseHandler'; const fetcher = (path: string) => { @@ -10,7 +11,7 @@ const fetcher = (path: string) => { export const useFeatures = () => { const { data, error, mutate } = useSWR( - 'api/admin/features', + formatApiPath('api/admin/features'), fetcher, { refreshInterval: 15 * 1000, // ms diff --git a/frontend/src/hooks/api/getters/useFeaturesArchive/useFeaturesArchive.ts b/frontend/src/hooks/api/getters/useFeaturesArchive/useFeaturesArchive.ts index 6ac46a5026..0eeefbfd58 100644 --- a/frontend/src/hooks/api/getters/useFeaturesArchive/useFeaturesArchive.ts +++ b/frontend/src/hooks/api/getters/useFeaturesArchive/useFeaturesArchive.ts @@ -1,6 +1,7 @@ import useSWR from 'swr'; import { FeatureSchema, FeaturesSchema } from 'openapi'; import handleErrorResponses from '../httpErrorResponseHandler'; +import { formatApiPath } from 'utils/formatPath'; export interface IUseFeaturesArchiveOutput { archivedFeatures?: FeatureSchema[]; @@ -19,9 +20,11 @@ export const useFeaturesArchive = ( projectId?: string ): IUseFeaturesArchiveOutput => { const { data, error, mutate, isLoading } = useSWR( - projectId - ? `/api/admin/archive/features/${projectId}` - : 'api/admin/features', + formatApiPath( + projectId + ? `/api/admin/archive/features/${projectId}` + : 'api/admin/features' + ), fetcher, { refreshInterval: 15 * 1000, // ms