Skip to content

Commit

Permalink
#3 Fix: localStorage 에러 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
dongree committed Jul 25, 2023
1 parent 90b3f22 commit 0bc3432
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/service/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,15 @@ export function checkEmail(email: string) {
}

export function saveToken(type: string, token: string) {
localStorage.setItem(type, token);
if (typeof window !== 'undefined') {
localStorage.setItem(type, token);
}
}

export function getToken(type: string) {
return localStorage.getItem(type);
if (typeof window !== 'undefined') {
return localStorage.getItem(type);
}
}

export function isLogin() {
Expand All @@ -96,5 +100,7 @@ export function isLogin() {
}

function clearToken() {
localStorage.clear();
if (typeof window !== 'undefined') {
localStorage.clear();
}
}

0 comments on commit 0bc3432

Please sign in to comment.