Revert online checker to navigator.onLine.
This commit is contained in:
parent
0567b9b729
commit
6c7e3d3a02
@ -4,12 +4,14 @@ const apiUrls = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
async function checkOnlineStatus(): Promise<boolean> {
|
async function checkOnlineStatus(): Promise<boolean> {
|
||||||
try {
|
return navigator.onLine;
|
||||||
const online = await fetch(apiUrls[Math.floor(Math.random() * apiUrls.length)]);
|
// TODO: Find better way of checking for device internet connectivity.
|
||||||
return online.status >= 200 && online.status < 300;
|
// try {
|
||||||
} catch (error) {
|
// const online = await fetch(apiUrls[Math.floor(Math.random() * apiUrls.length)]);
|
||||||
return false;
|
// return online.status >= 200 && online.status < 300;
|
||||||
}
|
// } catch (error) {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
export { checkOnlineStatus };
|
export { checkOnlineStatus };
|
||||||
|
Loading…
Reference in New Issue
Block a user