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(() => { useEffect(() => {
// Timer to call getHealth every 5 seconds // Timer to call getHealth every 5 seconds
const timer = setInterval(() => { const timer = setInterval(() => {
getHealth().catch((e) => { getHealth()
setFetchError(true); .then(() => {
}); if (fetchError) setFetchError(false);
})
.catch(() => {
setFetchError(true);
});
}, 5000); }, 5000);
// Clean up the timer on component unmount // Clean up the timer on component unmount