Created
July 29, 2020 20:16
-
-
Save gitdagray/ce445b1cf63e2553995ad2c23f4ca5ea to your computer and use it in GitHub Desktop.
checkOnlineStatus function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const checkOnlineStatus = async () => { | |
try { | |
const online = await fetch("/1pixel.png"); | |
return online.status >= 200 && online.status < 300; // either true or false | |
} catch (err) { | |
return false; // definintely offline | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment