From 0125643a4164b9af59a04bb5ae5e46344beec68f Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Wed, 22 Feb 2017 17:22:36 -0700 Subject: [PATCH] fix bug where no localstorage exists --- src/store/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/store/index.js b/src/store/index.js index 51da63c..b37cfbe 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -18,7 +18,9 @@ const store = new Vuex.Store({ plugins: [ createPersistedState({ getState(key) { - const state = lz.decompress(window.localStorage.getItem(key)); + const storedState = window.localStorage.getItem(key); + if (!storedState) return {}; + const state = lz.decompress(storedState); return JSON.parse(state); }, setState(key, state) {