Skip to content

Commit

Permalink
Try catch synchronous storage
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-ssg committed Mar 28, 2024
1 parent 6c8f450 commit c63b7f9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions async-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ export type AsyncStorageType = {
} | null
const AsyncStorage: AsyncStorageType = {
getItemSync: function(key) {
const data = localStorage.getItem(key);
return data || null
try {
const data = localStorage.getItem(key);
return data || null
} catch (e) {
return null
}
},
getItem: function (key, cb) {
return new Promise<any>((resolve, reject) => {
Expand Down

0 comments on commit c63b7f9

Please sign in to comment.