Created
March 26, 2018 16:47
-
-
Save erdoganoksuz/cc0174153c95a418142bb636c3c27d72 to your computer and use it in GitHub Desktop.
Service Worker Network Test
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
</head> | |
<body> | |
<h1 id="text">Heyy</h1> | |
<button onclick="getData()">GetData</button> | |
<script> | |
if ('serviceWorker' in navigator) { | |
navigator.serviceWorker.register('./sw.js').then((registration) => { | |
return navigator.serviceWorker.ready; | |
}).catch(function (error) { | |
console.log('Unable to register Service Worker.'); | |
}); | |
} else { | |
console.log('Service Worker functionality not supported.'); | |
} | |
function getData() { | |
fetch("https://jsonplaceholder.typicode.com/posts/1") | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment