From 3fcdb1fa122dd22312033867f9710a72a96fb76b Mon Sep 17 00:00:00 2001 From: Tyler Mabey Date: Thu, 13 Dec 2018 21:24:35 -0700 Subject: [PATCH 1/2] #147: improve the get cache function to handle errors when localStorage is not available --- src/cache.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cache.js b/src/cache.js index b3d26d0..2230ec7 100644 --- a/src/cache.js +++ b/src/cache.js @@ -25,6 +25,10 @@ export default { } }, get(key) { + // cache not available + if (!_hasLocalStorage) + return null; + const value = localStorage.getItem(CACHE_PREFIX + key); if (value) From 2c036cfe487ee67b0741c326fc9d07517348f2d9 Mon Sep 17 00:00:00 2001 From: Tyler Mabey Date: Sun, 16 Dec 2018 18:30:12 -0700 Subject: [PATCH 2/2] fix linting error --- src/cache.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cache.js b/src/cache.js index 2230ec7..666ed68 100644 --- a/src/cache.js +++ b/src/cache.js @@ -28,7 +28,7 @@ export default { // cache not available if (!_hasLocalStorage) return null; - + const value = localStorage.getItem(CACHE_PREFIX + key); if (value)