From 10b84ae04f8c7787e225b19226cc8c5dbe70a8b9 Mon Sep 17 00:00:00 2001 From: dykim Date: Mon, 5 Aug 2024 21:20:20 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=EB=B6=88=ED=95=84=EC=9A=94=20api=20cl?= =?UTF-8?q?ient=20=EC=BD=94=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/src/apis/index.ts | 19 ++++++------------- .../event-participant-floating-button.tsx | 5 +++-- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/apps/web/src/apis/index.ts b/apps/web/src/apis/index.ts index aa1e3f9..2ccedaf 100644 --- a/apps/web/src/apis/index.ts +++ b/apps/web/src/apis/index.ts @@ -5,19 +5,12 @@ import { EventApi } from "./event-api"; import { PhraseApi } from "./phrase-api"; const onRequestSuccess = (requestInit: RequestInit): RequestInit => { - if (typeof window !== "undefined" && requestInit.headers) { - const copyRequestInit: RequestInit = JSON.parse( - JSON.stringify(requestInit), - ); - copyRequestInit.headers = { - ...copyRequestInit.headers, - Authorization: "Bearer ", - }; - return copyRequestInit; - } - // server side getCookie logic - console.log("server side"); - return requestInit; + const copyRequestInit: RequestInit = JSON.parse(JSON.stringify(requestInit)); + copyRequestInit.headers = { + ...copyRequestInit.headers, + Authorization: "Bearer ", + }; + return copyRequestInit; }; const onResponseError: OnResponseError< diff --git a/apps/web/src/components/event-participant-floating-button.tsx b/apps/web/src/components/event-participant-floating-button.tsx index b1bd622..62cea56 100644 --- a/apps/web/src/components/event-participant-floating-button.tsx +++ b/apps/web/src/components/event-participant-floating-button.tsx @@ -7,7 +7,6 @@ import { apis } from "~/apis"; const EventParticipantFloatingButton = () => { const [isLoading, setIsLoading] = useState(true); const [eventList, setEventList] = useState>([]); - const eventMainItem = eventList?.[0]; const getPrizeList = async () => { const res = await apis.eventApi.getPrizeList(); @@ -20,7 +19,9 @@ const EventParticipantFloatingButton = () => { getPrizeList(); }, []); - if (isLoading || !("totalParticipantCount" in eventMainItem)) return null; + if (isLoading) return null; + const eventMainItem = eventList[0]; + if (!("totalParticipantCount" in eventMainItem)) return null; return (