diff --git a/apis/myPage.ts b/apis/myPage.ts index e93d31e..025963b 100644 --- a/apis/myPage.ts +++ b/apis/myPage.ts @@ -3,13 +3,15 @@ import request from "@utils/request"; import { getUserId } from "@apis"; interface GetUserInfoResponse { - name: string; - profile: string; - email: string; - follwer: number; - following: number; - video_cnt: number; - answer_video_cnt: number; + data: { + name: string; + profile: string; + email: string; + follower_cnt: number; + following_cnt: number; + video_cnt: number; + answer_video_cnt: number; + }; } export const getUserInfo = async (userId: number) => { diff --git a/views/myPage/UserInfo.tsx b/views/myPage/UserInfo.tsx index 170f4ed..0e86a2b 100644 --- a/views/myPage/UserInfo.tsx +++ b/views/myPage/UserInfo.tsx @@ -1,21 +1,39 @@ -import { FC } from "react"; +import { FC, useEffect } from "react"; import styled from "@emotion/styled"; import ImageWithDefault from "@components/ImageWithDefault"; +import { useQuery } from "react-query"; +import queryKey from "@constants/queryKey"; +import { getMyInfo } from "@apis/myPage"; -const UserInfo: FC = () => ( - - - - - name - - 팔로워 0 - 팔로잉 0 - - - - -); +const UserInfo: FC = () => { + const { data, isLoading, isError } = useQuery([queryKey.myInfo], getMyInfo); + const shortenData = data?.data.data; + + useEffect(() => { + console.log(data); + }, [data, isError, isLoading]); + + return ( + + + + + {shortenData?.name} + + + 팔로워 + {shortenData?.follower_cnt} + + + 팔로잉 + {shortenData?.following_cnt} + + + + + + ); +}; export default UserInfo; @@ -40,7 +58,7 @@ const Inner = styled.div` const FollowContainer = styled.div` display: flex; flex-direction: row; - column-gap: 8px; + column-gap: 10px; `; const Follow = styled.p`