-
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.
Merge branch 'develop-FE' into refactor/#642
- Loading branch information
Showing
6 changed files
with
62 additions
and
3 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