-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (28 loc) · 839 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
(() => {
window.addEventListener('load', () => {
fetch('https://opentdb.com/api.php?amount=1')
.then((response) => {
return response.json();
})
.then((data) => {
//console.log(data);
//console.log(data.results);
})
.catch((err) => {
//alert(err);
});
});
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('./service-worker.js').
then((registration) => {
console.log('registered is done');
console.log(registration);
}, (err) => {
console.log(err);
});
});
} else {
console.log(' No service worker support in this browser');
}
})();