From fc9d21d4df8169d1d53b33ffe662021fd4a4aebd Mon Sep 17 00:00:00 2001 From: SauceyRed Date: Mon, 26 May 2025 22:39:38 +0200 Subject: [PATCH] feat: remove fetchWithAuth --- utils/fetchWithAuth.ts | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 utils/fetchWithAuth.ts diff --git a/utils/fetchWithAuth.ts b/utils/fetchWithAuth.ts deleted file mode 100644 index df1f7bd..0000000 --- a/utils/fetchWithAuth.ts +++ /dev/null @@ -1,35 +0,0 @@ -import type { NitroFetchRequest, NitroFetchOptions } from "nitropack"; - -export default async (request: NitroFetchRequest, options: NitroFetchOptions = {}) => { - const accessToken = useCookie("access_token").value; - const { revoke } = useAuth(); - console.log("access token 2:", accessToken); - - let headers: HeadersInit = {}; - - if (accessToken) { - headers = { - ...options.headers, - "Authorization": `Bearer ${accessToken}` - }; - } else { - headers = { - ...options.headers - }; - } - - try { - const res = await $fetch(request, { - ...options, - headers, - credentials: "include" - }); - - return res; - } catch (error: any) { - if (error?.response?.status === 401) { - revoke(); - } - throw error; - } -}