Skip to content

Commit

Permalink
⚡️ :: localstorage -> cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanghyun0505 committed Oct 21, 2023
1 parent 0c304d7 commit be9737a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/libs/Cookie/cookie.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import cookie from "js-cookie";

class Cookie {
public getCookie(key: string): string | undefined | null {
public getCookie(key: string): string | undefined {
let item = undefined;
if (localStorage.getItem(key) !== undefined) {
item = localStorage.getItem(key);
if (cookie.get(key) !== undefined) {
item = cookie.get(key);
}
return item;
}

public setCookie(key: string, value: string): void {
localStorage.setItem(key, value);
cookie.set(key, value);
}

public removeCookie(key: string): void {
localStorage.removeItem(key);
cookie.remove(key);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/libs/Token/Token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import {
import cookie from "../Cookie/cookie";

interface Storage {
getToken(key: string): string | undefined | null;
getToken(key: string): string | undefined;
setToken(key: string, value: string): void;
clearToken(): void;
removeToken(key: string): void;
}

class Token implements Storage {
public getToken(key: string): string | undefined | null {
public getToken(key: string): string | undefined {
return cookie.getCookie(key);
}

Expand Down

0 comments on commit be9737a

Please sign in to comment.