aboutsummaryrefslogtreecommitdiff
path: root/public/javascripts/favorite.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/javascripts/favorite.js')
-rw-r--r--public/javascripts/favorite.js19
1 files changed, 12 insertions, 7 deletions
diff --git a/public/javascripts/favorite.js b/public/javascripts/favorite.js
index f10d954..8f48dc5 100644
--- a/public/javascripts/favorite.js
+++ b/public/javascripts/favorite.js
@@ -9,13 +9,18 @@ self._nodes = {
}
self.get = function () {
- const localStorageUser = JSON.parse(window.localStorage.getItem('fav'))
- if (localStorageUser == null) return
-
- const correctedUser = USERS.filter(user =>
- user.type === localStorageUser.type &&
- user.value === localStorageUser.value)[0]
- return correctedUser
+ try {
+ const localStorageUser = JSON.parse(window.localStorage.getItem('fav'))
+ if (localStorageUser == null) return
+
+ const correctedUser = USERS.filter(user =>
+ user.type === localStorageUser.type &&
+ user.value === localStorageUser.value)[0]
+ return correctedUser
+ } catch (e) {
+ self.delete()
+ return
+ }
}
self.set = function (user) {