Files
documenso/packages/lib/webstorage.ts
Timur Ercan 54cfe7daf3 📝
2023-02-20 14:51:50 +01:00

22 lines
547 B
TypeScript

export const localStorage = {
getItem(key: string) {
try {
return window.localStorage.getItem(key);
} catch (e) {
// In case storage is restricted. Possible reasons
// 1. Chrome/Firefox/... Incognito mode.
return null;
}
},
setItem(key: string, value: string) {
try {
window.localStorage.setItem(key, value);
} catch (e) {
// In case storage is restricted. Possible reasons
// 1. Chrome/Firefox/... Incognito mode.
// 2. Storage limit reached
return;
}
},
};