-
Notifications
You must be signed in to change notification settings - Fork 0
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
[NDD-86] 상태관리 라이브러리 추가 (순수 세팅 시간 1h/8h) (상태 관리 고민시간 4h/???) #25
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
969a3f4
chore: axios 라이브러리 추가
Yoon-Hae-Min 34d1d4a
chore: axios 기본 instance 생성
Yoon-Hae-Min dcbb8a9
chore: tanstack query 라이브러리 추가
Yoon-Hae-Min 3d2a9e2
chore: recoil 라이브러리 추가
Yoon-Hae-Min b8ca726
chore: tanstack query devtools 추가
Yoon-Hae-Min 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,50 @@ | ||
import { BASE_URL } from '@/constants/api'; | ||
import axios, { AxiosError } from 'axios'; | ||
|
||
const api = (() => { | ||
const axiosInstance = axios.create({ | ||
baseURL: BASE_URL, | ||
timeout: 3000, | ||
responseType: 'json', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
|
||
axiosInstance.interceptors.response.use( | ||
(response) => { | ||
return response; | ||
}, | ||
// TODO: console은 dev 환경에서만 동작해야 하고 실제 prod환경에서는 어떻게 처리할지 논의 해봐야함 | ||
(error: AxiosError) => { | ||
if (error.code === 'ECONNABORTED') { | ||
alert('서버에 이상이 있습니다.'); | ||
} | ||
switch (error.response?.status) { | ||
case 401: | ||
console.warn('401: 인증정보 없음'); | ||
break; | ||
case 403: | ||
console.warn('403: 권한 없음'); | ||
break; | ||
case 404: | ||
console.warn('404: 대상을 찾지 못함'); | ||
break; | ||
case 500: | ||
case 501: | ||
case 502: | ||
case 503: | ||
case 504: | ||
console.warn(`${error.response?.status}: 서버 오류`); | ||
break; | ||
default: | ||
console.error(`${error.response?.status}: unhandled error!`); | ||
break; | ||
} | ||
return Promise.reject(error); | ||
} | ||
); | ||
return axiosInstance; | ||
})(); | ||
|
||
export default api; |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
const BASEURL = ''; | ||
export const BASE_URL = ''; | ||
|
||
type Id = number; | ||
|
||
|
Oops, something went wrong.
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.
이건 그냥 궁금한건데 react-query와 recoil의 wrapping 순서가 의미가 있을까요?!
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.
별 의미는 없습니다~