Skip to content

Instantly share code, notes, and snippets.

@evuazeze
Last active November 20, 2018 16:15
Show Gist options
  • Save evuazeze/e26c06a1dbe9e7f3ff134c5c6085540b to your computer and use it in GitHub Desktop.
Save evuazeze/e26c06a1dbe9e7f3ff134c5c6085540b to your computer and use it in GitHub Desktop.
...
failedPostListener = () => {
navigator.serviceWorker.addEventListener('message', event => {
var form = document.getElementById('form');
// Alert displays the message sent from our service worker
alert(event.data.msg);
// Assuming personal-details database have been created with
// form_data object store.
// We simply write to form_data.
idb.open('personal-details', 1).then(function(db) {
const tx = db.transaction('form_data', 'readwrite');
const store = tx.objectStore('form_data');
store.put({name: `${form[0].value}`});
})
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment