if health returns, the fetchError error is removed

This commit is contained in:
Lucas Oliveira 2024-01-05 21:18:16 -03:00
commit 18b2f5e970

View file

@ -150,9 +150,13 @@ export default function App() {
useEffect(() => {
// Timer to call getHealth every 5 seconds
const timer = setInterval(() => {
getHealth().catch((e) => {
setFetchError(true);
});
getHealth()
.then(() => {
if (fetchError) setFetchError(false);
})
.catch(() => {
setFetchError(true);
});
}, 5000);
// Clean up the timer on component unmount