Revert online checker to navigator.onLine.

This commit is contained in:
Spencer Ofwiti 2021-09-03 02:13:56 +03:00
parent 0567b9b729
commit 6c7e3d3a02

View File

@ -4,12 +4,14 @@ const apiUrls = [
];
async function checkOnlineStatus(): Promise<boolean> {
try {
const online = await fetch(apiUrls[Math.floor(Math.random() * apiUrls.length)]);
return online.status >= 200 && online.status < 300;
} catch (error) {
return false;
}
return navigator.onLine;
// TODO: Find better way of checking for device internet connectivity.
// try {
// const online = await fetch(apiUrls[Math.floor(Math.random() * apiUrls.length)]);
// return online.status >= 200 && online.status < 300;
// } catch (error) {
// return false;
// }
}
export { checkOnlineStatus };