Skip to content

Instantly share code, notes, and snippets.

@tofumatt
Created October 23, 2018 00:29
Show Gist options
  • Save tofumatt/1a97169878e232c96870ca422580cee6 to your computer and use it in GitHub Desktop.
Save tofumatt/1a97169878e232c96870ca422580cee6 to your computer and use it in GitHub Desktop.
// Our config values we want to store offline.
var config = {
fullName: document.getElementById('name').getAttribute('value'),
userId: document.getElementById('id').getAttribute('value')
};
// Let's save it for the next time we load the app.
localStorage.setItem('config', JSON.stringify(config));
// The next time we load the app, we can do:
var config = JSON.parse(localStorage.getItem('config'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment