// Trigger sth, when Connection comes back | Connection gets lost
function poopityScoop(){
window.ononline = (event) => {
console.log("Back Online")
};
window.onoffline = (event) => {
console.log("Connection Lost")
};
}
// check the current Connection State
console.log(navigator.onLine)
// true - When internet connection is detected.
// false - When internet connection is not detected.
var condition = navigator.onLine ? 'online' : 'offline';
if (condition === 'online') {
console.log('ONLINE');
fetch('https://www.google.com/', { // Check for internet connectivity
mode: 'no-cors',
})
.then(() => {
console.log('CONNECTED TO INTERNET');
}).catch(() => {
console.log('INTERNET CONNECTIVITY ISSUE');
} )
}else{
console.log('OFFLINE')
}