Skip to content

Commit

Permalink
chore: create storage locally
Browse files Browse the repository at this point in the history
  • Loading branch information
tassioFront committed Sep 2, 2021
1 parent 82c57b2 commit 05839e8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ const Profile = () => import("profile/Profile");
const Logout = () => import("auth/Logout");
const CartIcon = () => import("cart/CartIcon");
import { emitter, EVENT_KEYS, userData } from "../dealful";
import { emitter, EVENT_KEYS } from "../dealful";
import { userData } from "../services/storage";
export default {
name: "Navbar",
data: () => ({ drawer: null, user: userData() }),
components: { Profile, Logout , CartIcon },
components: { Profile, Logout, CartIcon },
methods: {
menuToggle() {
this.$emit("menuToggle");
Expand Down
11 changes: 11 additions & 0 deletions src/services/storage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { STORAGE_KEYS } from "../dealful";

export const userData = () => {
const userData = localStorage.getItem(STORAGE_KEYS.USER_DATA);

try {
return JSON.parse(userData);
} catch (error) {
throw Error("user data is empty");
}
};

0 comments on commit 05839e8

Please sign in to comment.