2023-02-20 14:49:17 +01:00
|
|
|
export const localStorage = {
|
|
|
|
|
getItem(key: string) {
|
|
|
|
|
try {
|
|
|
|
|
return window.localStorage.getItem(key);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
// In case storage is restricted. Possible reasons
|
2023-02-20 14:51:50 +01:00
|
|
|
// 1. Chrome/Firefox/... Incognito mode.
|
2023-02-20 14:49:17 +01:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
setItem(key: string, value: string) {
|
|
|
|
|
try {
|
|
|
|
|
window.localStorage.setItem(key, value);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
// In case storage is restricted. Possible reasons
|
2023-02-20 14:51:50 +01:00
|
|
|
// 1. Chrome/Firefox/... Incognito mode.
|
2023-02-20 14:49:17 +01:00
|
|
|
// 2. Storage limit reached
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|