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,7 +150,11 @@ 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()
.then(() => {
if (fetchError) setFetchError(false);
})
.catch(() => {
setFetchError(true); setFetchError(true);
}); });
}, 5000); }, 5000);