127.0.0.1:8000 budget / master src / js / utils / storage.js
master

Tree @master (Download .tar.gz)

storage.js @masterraw · history · blame

const storage = window.localStorage;

module.exports = {
    set: function(key, data) {
        storage.setItem(key, JSON.stringify(data));
        // Need to read it to save it
        // https://stackoverflow.com/questions/13292744/why-isnt-localstorage-persisting-in-chrome
        storage.getItem(key);
    },
    get: function(key) {
        // returns "" if no cookie stored
        return JSON.parse(storage.getItem(key) || '""');
    }
}