File tree Expand file tree Collapse file tree 5 files changed +38
-0
lines changed Expand file tree Collapse file tree 5 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ import { useQuery } from '@tanstack/react-query' ;
2+
3+ import { USER_QUERY_OPTIONS } from '@shared/api/domain/mypage/queries' ;
4+
15const MyPage = ( ) => {
6+ const { data : userData } = useQuery ( USER_QUERY_OPTIONS . PROFILE ( ) ) ;
7+ console . log ( userData ) ;
8+
29 return < div > MyPage</ div > ;
310} ;
411
Original file line number Diff line number Diff line change 1+ import { queryOptions } from '@tanstack/react-query' ;
2+
3+ import { api } from '@shared/api/config/instance' ;
4+ import { UserProfile } from '@shared/api/types/types' ;
5+ import { END_POINT } from '@shared/constants/end-point' ;
6+ import { USER_QUERY_KEY } from '@shared/constants/query-key' ;
7+
8+ export const USER_QUERY_OPTIONS = {
9+ PROFILE : ( ) => {
10+ return queryOptions ( {
11+ queryKey : USER_QUERY_KEY . PROFILE ( ) ,
12+ queryFn : getUserProfile ,
13+ } ) ;
14+ } ,
15+ } ;
16+
17+ export const getUserProfile = async ( ) : Promise < UserProfile | null > => {
18+ const response = await api . get ( END_POINT . GET_USER_INFO ) . json < UserProfile > ( ) ;
19+ return response ;
20+ } ;
Original file line number Diff line number Diff line change 1+ import { paths } from '@shared/types/schema' ;
2+
3+ export type UserProfile =
4+ paths [ '/users/info' ] [ 'get' ] [ 'responses' ] [ '200' ] [ 'content' ] [ '*/*' ] ;
Original file line number Diff line number Diff line change 1+ export const END_POINT = {
2+ GET_USER_INFO : 'users/info' ,
3+ } ;
Original file line number Diff line number Diff line change 1+ export const USER_QUERY_KEY = {
2+ ALL : [ 'users' ] ,
3+ PROFILE : ( ) => [ ...USER_QUERY_KEY . ALL , 'profile' ] ,
4+ } as const ;
You can’t perform that action at this time.
0 commit comments