Skip to content

Commit

Permalink
fix: response 타입 동일화
Browse files Browse the repository at this point in the history
  • Loading branch information
semnil5202 committed Sep 20, 2023
1 parent 41cd2b4 commit 09fa77e
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions frontend/src/apis/getApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,11 @@ async function refreshToken(headers: Headers): Promise<Response> {
}),
});

const responseData = await refreshResponse;
const promiseResponse = refreshResponse;
refreshResponse = null;

// 서버 응답이 성공적인지 확인합니다.
if (!responseData.ok) {
console.log('refreshResponse.ok하지 못함');
throw new Error('Failed to refresh access token.');
}

// 새로운 엑세스 토큰을 반환합니다.
return responseData;
return promiseResponse;
} catch (error) {
// 네트워크 요청 실패 또는 예외 발생 시 예외를 캐치하여 처리합니다.
console.error('네트워크 요청 실패 또는 예외 발생:', error);
Expand All @@ -52,7 +46,19 @@ const isTokenExpired = (token: string) => {

async function updateToken(headers: Headers) {
const response = await refreshToken(headers);

console.log('50, response : ', response);

// 서버 응답이 성공적인지 확인합니다.
if (!response.ok) {
console.log('refreshResponse.ok하지 못함');
throw new Error('Failed to refresh access token.');
}

const newToken = await response.json();

console.log(newToken);

localStorage.setItem('userToken', newToken.accessToken);
}

Expand Down

0 comments on commit 09fa77e

Please sign in to comment.