From 5a17f0363781c1a966db10f23ab231450e9896ab Mon Sep 17 00:00:00 2001 From: afds4567 <33995840+afds4567@users.noreply.github.com> Date: Wed, 20 Sep 2023 00:46:02 +0900 Subject: [PATCH] =?UTF-8?q?hotfix:=20=EC=9E=AC=EB=B0=9C=EA=B8=89=EC=8B=9C?= =?UTF-8?q?=20getItem=20=EB=B6=80=EB=B6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/apis/getApi.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/frontend/src/apis/getApi.ts b/frontend/src/apis/getApi.ts index bf9f978e4..a0c455297 100644 --- a/frontend/src/apis/getApi.ts +++ b/frontend/src/apis/getApi.ts @@ -11,17 +11,15 @@ const decodeToken = (token: string) => { async function refreshToken(headers: Headers): Promise { console.log('L12 refreshTOken이 호출은 되었는지 확인', headers); - const parsedToken = JSON.parse(localStorage.getItem('userToken') as string); - console.log('getAPI Line 14', parsedToken); - const { userToken } = parsedToken; - console.log('userToken', userToken); + const accessToken = localStorage.getItem('userToken'); + console.log('getAPI Line 14', accessToken); try { // 서버에 새로운 엑세스 토큰을 요청하기 위한 네트워크 요청을 보냅니다. const refreshResponse = await fetch(`${DEFAULT_PROD_URL}/refresh-token`, { method: 'POST', headers, body: JSON.stringify({ - accessToken: userToken, + accessToken: accessToken, }), }); @@ -32,7 +30,7 @@ async function refreshToken(headers: Headers): Promise { } console.log('refreshResponse', refreshResponse); - + console.log('refreshResponse.text()', refreshResponse.text()); // 새로운 엑세스 토큰을 반환합니다. return await refreshResponse.text(); } catch (error) { @@ -59,6 +57,7 @@ async function withTokenRefresh(callback: () => Promise): Promise { console.log(`Authorization : Bearer ${userToken}`); //새로운 토큰 재발급 userToken = await refreshToken(headers); + console.log('L59 userToken', userToken); localStorage.setItem('userToken', userToken); console.log('localStorage에 새로운 토큰 적용 성공!'); }