-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: http 모듈 추가 * feat: Profile get api 추가 * feat: useProfileList hook 추가 * refactor: fetchGet을 useProfileList로 변경 * refactor: getProfile api에 url 직접 입력으로 변경 * refactor: 사용하지 않는 매개 변수 삭제 및 queryFn 수정 * refactor: 필요없는 코드 삭제 * refactor: query refetch 추가 * refactor: tanstack query 기본 설정 추가 * refactor: profile리스트 가져오는 부분 query 추가 및 필요없는 코드 삭제 * refactor: useQuery를 useSuspenseQuery로 변경 * refactor: Profile에 Query suspense 적용
- Loading branch information
Showing
6 changed files
with
73 additions
and
23 deletions.
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,36 @@ | ||
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios'; | ||
|
||
const API_PREFIX = 'api'; | ||
|
||
export const BASE_URL = | ||
process.env.APP_URL || `https://mapbefine.com/${API_PREFIX}`; | ||
|
||
const axiosInstance = axios.create({ | ||
baseURL: BASE_URL, | ||
timeout: 5000, | ||
}); | ||
|
||
export interface HttpClient extends AxiosInstance { | ||
get<T = unknown>(url: string, config?: AxiosRequestConfig): Promise<T>; | ||
post<T = unknown>( | ||
url: string, | ||
data?: any, | ||
config?: AxiosRequestConfig, | ||
): Promise<T>; | ||
patch<T = unknown>( | ||
url: string, | ||
data?: any, | ||
config?: AxiosRequestConfig, | ||
): Promise<T>; | ||
put<T = unknown>( | ||
url: string, | ||
data?: any, | ||
config?: AxiosRequestConfig, | ||
): Promise<T>; | ||
delete<T = unknown>(url: string, config?: AxiosRequestConfig): Promise<T>; | ||
} | ||
|
||
export const http: HttpClient = axiosInstance; | ||
|
||
// axios.interceptors.request.use() | ||
axios.interceptors.response.use((res) => res.data) |
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,6 @@ | ||
import { http } from './http'; | ||
import { TopicCardProps } from '../../types/Topic'; | ||
|
||
export const getProfile = () => { | ||
return http.get<TopicCardProps[] | null>("/members/my/topics"); | ||
}; |
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,13 @@ | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
import { getProfile } from '../../apis/Patrick'; | ||
|
||
const useProfileList = () => { | ||
const { data, refetch } = useSuspenseQuery({ | ||
queryKey: ['profileList'], | ||
queryFn: getProfile, | ||
}); | ||
|
||
return { data, refetch }; | ||
}; | ||
|
||
export default useProfileList; |
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