Refactor[API]: axios 기반 API 구조 리팩터링 #104
Open
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.
수정 사유 Reason for modification
소스를 수정한 사유가 무엇인지 체크해 주세요. Please check the reason you modified the source. ([X] X는 대문자여야 합니다.)
수정된 소스 내용 Modified source
검토자를 위해 수정된 소스 내용을 설명해 주세요. Please describe the modified source for reviewers.
기존 fetch 기반에서 Axios로 전환하기 위해 일부 컴포넌트를 우선 리팩터링하였습니다.
컴포넌트 내부의 Server 로직과 UI 로직을 분리하기 위해 API 모듈을 정의하였으며,
src/api/services/{컴포넌트명}경로에 컴포넌트명과 동일한 이름으로 구성하여 구조적 일관성을 유지했습니다.Axios 도입으로 얻은 이점은 다음과 같습니다.
Interceptor 분리
모든 API 요청에서 중복되는 Auth, Error 처리를 interceptor에서 일관적으로 제어할 수 있습니다.
자동 JSON 파싱
fetch는
await res.json()호출이 필요하지만, Axios는response.data로 바로 접근 가능합니다.쿼리 파라미터 직렬화 편의성
params옵션으로 객체를 전달해 직관적이고 간단하게 관리할 수 있습니다.JUnit 테스트 JUnit tests
테스트를 완료하셨으면 다음 항목에 [대문자X]로 표시해 주세요. When you're done testing, check the following items.
테스트 브라우저 Test Browser
테스트를 진행한 브라우저를 선택해 주세요. Please select the browser(s) you ran the test on. (다중 선택 가능 you can select multiple) [X] X는 대문자여야 합니다.
테스트 스크린샷 또는 캡처 영상 Test screenshots or captured video
테스트 전과 후의 스크린샷 또는 캡처 영상을 이곳에 첨부해 주세요. Please attach screenshots or video captures of your before and after tests here.