From cb5fa29990d7de77418be345527fa44f63d6bbbe Mon Sep 17 00:00:00 2001 From: shimdokite Date: Mon, 6 May 2024 22:55:58 +0900 Subject: [PATCH] =?UTF-8?q?[FE]=20=E2=99=BB=EF=B8=8F=20=ED=86=A0=ED=81=B0?= =?UTF-8?q?=20=EA=B4=80=EB=A0=A8=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/api/axios.ts | 9 +++------ client/src/utils/checkForToken.ts | 8 +++----- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/client/src/api/axios.ts b/client/src/api/axios.ts index b4ae54ec..fa596df3 100644 --- a/client/src/api/axios.ts +++ b/client/src/api/axios.ts @@ -1,15 +1,12 @@ import axios, { AxiosResponse } from 'axios'; -import LocalStorage from './localStorage'; - import checkForToken from '@/utils/checkForToken'; +import LocalStorage from '@/utils/localStorage'; const { authVerify, storageData } = checkForToken(); -const accessToken = - typeof window !== 'undefined' ? storageData.state.accessToken : null; -const refreshToken = - typeof window !== 'undefined' ? storageData.state.refreshToken : null; +const accessToken = storageData?.state.accessToken; +const refreshToken = storageData?.state.refreshToken; export const instance = axios.create({ baseURL: process.env.NEXT_PUBLIC_API_URL, diff --git a/client/src/utils/checkForToken.ts b/client/src/utils/checkForToken.ts index b31c1223..854c15ea 100644 --- a/client/src/utils/checkForToken.ts +++ b/client/src/utils/checkForToken.ts @@ -1,12 +1,10 @@ -import LocalStorage from '@/api/localStorage'; +import LocalStorage from './localStorage'; const checkForToken = () => { const storageData = LocalStorage.getItem('user-key'); - const accessToken = - typeof window !== 'undefined' ? storageData.state.accessToken : null; - const refreshToken = - typeof window !== 'undefined' ? storageData.state.refreshToken : null; + const accessToken = storageData?.state.accessToken; + const refreshToken = storageData?.state.refreshToken; const parseJWT = (token: string | null) => { if (token) return JSON.parse(atob(token.split('.')[1]));