-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor/#511 프론트의 토큰 만료 검증로직을 삭제하고 Axios를 도입한다. #554
Merged
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
3ec2b5f
config: axios 설치
Creative-Lee 895be60
feat: axios 인스턴스 및 인터셉터 구현
Creative-Lee 69605c1
refactor: 엑세스 토큰 refresh remote 함수 분리
Creative-Lee 89bdb5f
refactor: 분리되지 않은 type, remote 함수 분리
Creative-Lee e10bfbe
refactor: remote 함수의 fetcher 의존성 제거 및 인스턴스 적용
Creative-Lee f2c79ee
refactor: 로그인 remote 함수 분리
Creative-Lee 3ecd234
feat: 메인 페이지 장르별 fetch msw 구현
Creative-Lee db04ff0
chore: 불필요한 파일 제거
Creative-Lee a2bbcee
chore: remote 함수 중복 래핑 hook 삭제 및 코드 이동
Creative-Lee c287cfe
refactor: remote 함수 query parameter 처리 방식 통일
Creative-Lee d06887a
chore: import 방식 변경
Creative-Lee a4a83df
chore: auth 관련 remote함수 auth/하위로 이동
Creative-Lee 4f858e9
fix: refresh 요청 API 명세에 맞게 로직 수정
Creative-Lee 09cf9f3
refactor: 최종 만료시 로그인 페이지 리다이렉트 처리
Creative-Lee e6bfcfe
refactor: 타입 분리
Creative-Lee 744fbff
refactor: 인터셉터 refresh 중복 요청 방지 기능 추가
Creative-Lee 2166a72
refactor: 에러응답 타입 분리
Creative-Lee 8e0a22f
chore: fetcher 및 토큰 만료 검증 파일 제거
Creative-Lee 0fbcfde
refactor: 함수 네이밍 개선
Creative-Lee 6755702
chore: 주석 수정
Creative-Lee 0f87b75
refactor: promise 변수 null 초기화 코드 위치 이동
Creative-Lee dbf9655
style: promise 변수 라인 변경
Creative-Lee 500cae1
refactor: config type 변경 및 린트 주석 제거
Creative-Lee ea5e89b
Merge branch 'main' into refactor/#511
Creative-Lee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { clientBasic } from './axios'; | ||
|
||
interface RefreshAccessTokenRes { | ||
accessToken: string; | ||
} | ||
|
||
export const postRefreshAccessToken = async (staleAccessToken: string) => { | ||
const { data } = await clientBasic.post<RefreshAccessTokenRes>('/reissue', staleAccessToken); | ||
|
||
return data; | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💬 현재 해당 함수는 구현부에서 await 1번하고, 사용처에서 await를 1번 더 해요. 객체분해할당만 하는 것이기 때문에 함수 구현부 내부에서는 굳이 await를 하지 않아도 되지 않을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
말씀하신 부분이 잘 이해가 안되어서 그런데
promise가 이행된 후에만 새 변수에 할당이 가능하지 않나요?
구조분해할당만을 위한 함수 구현부 내부의 await가 없어도 된다는 말씀이 맞을까용?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이것은 이제 도밥이 판단해야 할 것 같아요! 정말 해당함수에서 구조분해할당을 해서
data
를 가져와야 하는지요! 다만, 제가 말씀드리고 싶은 것은 그렇게 함으로써 async-await를 두 번 사용하게 된다는 점입니다!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아하 '구조분해 할당을 위해 await가 필요없다' 가 아니고,
'await + 구조분해 할당을 해서 가져와야 하는가~ 가' 주안점이었군요!
오 그럼 궁금한게 있는데, await가 2번 사용되면 단점이있나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ukkodeveloper
바깥에서
data
({ asccessToken }
)를 바로 쓰려면data
를 풀어내서 내보내야 됩니다.그냥 내보내게 되면 response 객체이겠죠.
다만 async/await가 불편하다면 then이 붙은 promise를 내보내면 될 것 같네요.
둘의 차이는 어떨지 더 알아봐야 알 것 같은데, 똑똑한 여러분들이 알려주실거라 믿습니다 😄