From c352c790066811d5ef964130c58ef6e41c6a3f2d Mon Sep 17 00:00:00 2001 From: Brokyeom Date: Tue, 19 Jul 2022 17:05:40 +0900 Subject: [PATCH] =?UTF-8?q?[=20=20chore=20=20]=20useSWR=20mocking=20?= =?UTF-8?q?=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/api/community.ts | 1 - pages/community/index.tsx | 17 +++++++++++------ types/community.ts | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/core/api/community.ts b/core/api/community.ts index 918511f..282dd6a 100644 --- a/core/api/community.ts +++ b/core/api/community.ts @@ -14,7 +14,6 @@ export const useGetCommunityList = () => { const { data, error } = useSWR('/board', baseInstance.get, { errorRetryCount: 3, }); - console.log(`데이터 ${data}`); return { communityList: data, diff --git a/pages/community/index.tsx b/pages/community/index.tsx index aca0875..648a213 100644 --- a/pages/community/index.tsx +++ b/pages/community/index.tsx @@ -24,11 +24,13 @@ export default function community() { useGetCommunityList() as GetCommunityList; useEffect(() => { + console.log(communityList); if (communityList) { - let data = communityList as CommunityData[]; + let data = communityList.data as CommunityData[]; data = data.filter( (_, idx) => (currentPage - 1) * 10 <= idx && idx < currentPage * 10, ); + console.log(data); setContentList(data); window.scrollTo({ top: 0, @@ -36,6 +38,7 @@ export default function community() { }); } }, [contentList, currentPage]); + console.log(contentList); // setIsLoading(true); // fetch('/board') // .then((res) => res.json()) @@ -70,11 +73,13 @@ export default function community() { - + {!isLoading && !isError && communityList && ( + + )} )} diff --git a/types/community.ts b/types/community.ts index 9abba27..24c849e 100644 --- a/types/community.ts +++ b/types/community.ts @@ -35,7 +35,7 @@ export interface PostCommentBody { } export interface GetCommunityList { - communityList: CommunityData[]; + communityList: { data: CommunityData[] }; isLoading: boolean; isError: string; }