-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: axios instance 및 interceptor 작성 #77
Merged
Merged
Conversation
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
✅ Deploy Preview for moabam-storybook ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
nayeon-hub
approved these changes
Nov 6, 2023
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.
LGTM👍🏻
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🧩 이슈 번호
✅ 작업 사항
baseURL
을 옵션에 담은 axios 인스턴스 생성response
에 대해서{ ...data, statusCode: status }
데이터를 파싱하는 interceptor 작성👩💻 공유 포인트 및 논의 사항
응답 객체 내부의
data
를 번거롭게 파싱하지 않아도 되는 인터셉터를 만들었어요.공통
statusCode
라는 프로퍼티로 받아요.data
객체의 모든 데이터는 전개 연산자로 그대로 받게 되어있어요.사용 예시
여기에서
data
에 실제로 들어가게 되는 내용은 아래와 같아요:정의한
CustomAxiosInstance
인터페이스를 기반으로 데이터에 대한 타입 추론이 돼요.baseInstance
application/json
형식의 데이터를 전달할 때 사용하는 인스턴스에요.formDataInstance
multipart/form-data
형식의 데이터를 전달할 때 사용하는 인스턴스에요.사용 예시