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]));