From d9b03980f7609ccea434adec4a07e13ff8ed6c6a Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Wed, 23 Aug 2023 14:59:20 -0300 Subject: [PATCH] fix(typesContext.tsx): remove unnecessary code that checks result status and fetches health on error fix(typesContext.tsx): handle error when fetching types and set fetchError state to true --- src/frontend/src/contexts/typesContext.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/frontend/src/contexts/typesContext.tsx b/src/frontend/src/contexts/typesContext.tsx index bcaf67bf1..189f61af0 100644 --- a/src/frontend/src/contexts/typesContext.tsx +++ b/src/frontend/src/contexts/typesContext.tsx @@ -44,11 +44,6 @@ export function TypesProvider({ children }: { children: ReactNode }) { async function getTypes(): Promise { try { const result = await getAll(); - if (result?.status !== 200) { - let health = await getHealth().catch((e) => { - setFetchError(true); - }); - } // Make sure to only update the state if the component is still mounted. if (isMounted && result?.status === 200) { setLoading(false); @@ -82,10 +77,13 @@ export function TypesProvider({ children }: { children: ReactNode }) { } } catch (error) { console.error("An error has occurred while fetching types."); + await getHealth().catch((e) => { + console.log("entrou"); + setFetchError(true); + }); } } - // Start the initial interval. getTypes(); }, []);