Skip to content

Instantly share code, notes, and snippets.

@igorfelipee
Created August 3, 2017 13:08
Show Gist options
  • Save igorfelipee/7cbbc825318a7c57ba9648807ab0bb8d to your computer and use it in GitHub Desktop.
Save igorfelipee/7cbbc825318a7c57ba9648807ab0bb8d to your computer and use it in GitHub Desktop.
function save_data(data, id) {
if (!window.localStorage || !window.JSON || !id) {
return;
}
window.localStorage.setItem(id, JSON.stringify(data));
}
function get_data(key) {
console.log("getting data");
if (!window.localStorage || !window.JSON || !key) {
console.log('Erro');
return;
}
if (!window.localStorage.getItem(key)) {
return;
console.log("!item");
}
return window.localStorage.getItem(key);
}
export { save_data, get_data };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment