Last active
November 20, 2018 16:15
-
-
Save evuazeze/e26c06a1dbe9e7f3ff134c5c6085540b to your computer and use it in GitHub Desktop.
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
... | |
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