Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
Moved storage.getItem function (#299)
Browse files Browse the repository at this point in the history
Moved `storage.getItem` function call outside of silent `try {} catch {}`.

The silent `try {} catch {}` block was hiding an error from appearing, a mistake I was making inside my `getItem` function, so I didn't understand what was going on.

I understand the `try {} catch {}` block is there to hide a `JSON.parse` error,
so I left this one inside it.
  • Loading branch information
yachaka committed Aug 24, 2020
1 parent c58fa28 commit e616e4a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ export default function <State>(
const key = options.key || "vuex";

function getState(key, storage) {
let value;
const value = storage.getItem(key);

try {
return (value = storage.getItem(key)) && typeof value !== "undefined"
return (typeof value !== "undefined")
? JSON.parse(value)
: undefined;
} catch (err) {}
Expand Down

0 comments on commit e616e4a

Please sign in to comment.