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
This commit is contained in:
anovazzi1 2023-08-23 14:59:20 -03:00
commit d9b03980f7

View file

@ -44,11 +44,6 @@ export function TypesProvider({ children }: { children: ReactNode }) {
async function getTypes(): Promise<void> {
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();
}, []);