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:
parent
ea105ee7af
commit
d9b03980f7
1 changed files with 4 additions and 6 deletions
|
|
@ -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();
|
||||
}, []);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue