Skip to content

Commit

Permalink
fix(storage): try/catch localStorage.get
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianAndersen committed Aug 23, 2024
1 parent 6a1b624 commit d16bbdd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
6 changes: 5 additions & 1 deletion src/api/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ export const add = (key: string, value: string): boolean => {
};

export const get = (key: string): string | null => {
return localStorage.getItem(key);
try {
return localStorage.getItem(key);
} catch {
return null;
}
};

export const remove = (key: string): boolean => {
Expand Down
13 changes: 4 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1625,15 +1625,10 @@ callsites@^3.0.0:
resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73"
integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==

caniuse-lite@^1.0.30001579:
version "1.0.30001587"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001587.tgz#a0bce920155fa56a1885a69c74e1163fc34b4881"
integrity sha512-HMFNotUmLXn71BQxg8cijvqxnIAofforZOwGsxyXJ0qugTdspUF4sPSJ2vhgprHCB996tIDzEq1ubumPDV8ULA==

caniuse-lite@^1.0.30001629:
version "1.0.30001639"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001639.tgz#972b3a6adeacdd8f46af5fc7f771e9639f6c1521"
integrity sha512-eFHflNTBIlFwP2AIKaYuBQN/apnUoKNhBdza8ZnW/h2di4LCZ4xFqYlxUxo+LQ76KFI1PGcC1QDxMbxTZpSCAg==
caniuse-lite@^1.0.30001579, caniuse-lite@^1.0.30001629:
version "1.0.30001651"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001651.tgz"
integrity sha512-9Cf+Xv1jJNe1xPZLGuUXLNkE1BoDkqRqYyFJ9TDYSqhduqA4hu4oR9HluGoWYQC/aj8WHjsGVV+bwkh0+tegRg==

caseless@~0.12.0:
version "0.12.0"
Expand Down

0 comments on commit d16bbdd

Please sign in to comment.