From bb37d84d99e56de09d40ba8fda0eab79828012dc Mon Sep 17 00:00:00 2001 From: dank074 Date: Thu, 22 Dec 2022 21:22:16 -0600 Subject: [PATCH] catch possible permission error from localstorage (#103) --- src/api/utils/GetLocalStorage.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/api/utils/GetLocalStorage.ts b/src/api/utils/GetLocalStorage.ts index e8ba878d..769df6d7 100644 --- a/src/api/utils/GetLocalStorage.ts +++ b/src/api/utils/GetLocalStorage.ts @@ -1 +1,11 @@ -export const GetLocalStorage = (key: string) => JSON.parse(window.localStorage.getItem(key)) as T ?? null; +export const GetLocalStorage = (key: string) => +{ + try + { + JSON.parse(window.localStorage.getItem(key)) as T ?? null + } + catch(e) + { + return null; + } +}