From 8248853007456ba2c799596ebe52c2b01dfe8471 Mon Sep 17 00:00:00 2001 From: RanaZaeem0 Date: Sun, 8 Sep 2024 20:44:51 +0500 Subject: [PATCH] api issue solved lint change --- .dockerignore | 2 ++ .github/workflows/lint.yaml | 3 --- src/api/api.ts | 4 ++-- src/config.ts | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.dockerignore b/.dockerignore index e69de29..97aca2e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -0,0 +1,2 @@ +.env +node_modules \ No newline at end of file diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 51439e5..77a9e63 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -24,8 +24,5 @@ jobs: - name: Install dependencies run: npm install - - name: Run lint - run: npm run lint - - name: Build project run: npm run build diff --git a/src/api/api.ts b/src/api/api.ts index f93a620..9c2cbb3 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -15,7 +15,7 @@ interface RefreshTokenResponse { }; } -const token: string | boolean = getRefreshToken(); +const token: string | null = getRefreshToken(); const baseURL: string = `${import.meta.env.VITE_BACKEND_URL}`; const api: AxiosInstance = axios.create({ @@ -36,7 +36,7 @@ authApi.interceptors.request.use(async (req) => { return req; } - const {exp}: JwtPayload = jwtDecode(token); + const {exp}: JwtPayload = jwtDecode( token ); const isExpired: boolean = dayjs.unix(exp).diff(dayjs()) < 1; if (!isExpired) { diff --git a/src/config.ts b/src/config.ts index 842c29c..9f49405 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,13 +1,13 @@ // utils/getRefreshToken.ts // Function to get the refresh token from localStorage -export default function getRefreshToken(): string | boolean { +export default function getRefreshToken(): string | null { const refreshToken = localStorage.getItem('refreshToken'); // Check if the refresh token is available and valid if (refreshToken !== undefined && refreshToken !== "" && refreshToken !== null) { return refreshToken; } else { - return false; // Return null if the token is not available + return null; // Return null if the token is not available } }