From 79c058ef80463180159e4151b801c06887f46bef Mon Sep 17 00:00:00 2001 From: KimSehyeoun Date: Tue, 13 Feb 2024 20:35:47 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B2=AB=EB=B2=88=EC=A7=B8=20=EA=B8=80?= =?UTF-8?q?=EC=9E=90=20=EA=B2=80=EC=83=89=20=EC=8B=9C=20=EB=AF=B8=20?= =?UTF-8?q?=EB=B0=98=EC=98=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/SearchResultPage.tsx | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/pages/SearchResultPage.tsx b/src/pages/SearchResultPage.tsx index d148f7d..c64ef94 100644 --- a/src/pages/SearchResultPage.tsx +++ b/src/pages/SearchResultPage.tsx @@ -68,6 +68,7 @@ const SearchResult = () => { return searchData.then(value => value.data.result); }) const responses = await Promise.all(requests); + console.log(responses); responses.forEach((response) => { const ivideos = response.videos as IVideo[]; dataDuplicateHandler(ivideos, inputValues); @@ -96,20 +97,18 @@ const SearchResult = () => { const dataDuplicateHandler = (videos : IVideo[], check : string) => { const newData = videos.filter((value) => { - return !data.some((item) => item.video_id === value.video_id); - }).map((video) => { - const formattedContent = formatContent(video.content, check); - const formattedTitle = formatContent(video.title, check); - const formattedDescription = formatContent(video.description, check) - - return { - ...video, - title: formattedTitle, - description : formattedDescription, - content: formattedContent - }; - }); - setData(data.concat(newData)); + return !data.some((item) => item.video_id === value.video_id); + }) + const mappingData = newData.map((video) => { + const markdata = { + ...video, + title: formatContent(video.title, check), + description : formatContent(video.description, check), + content: formatContent(video.content, check) + }; + setData([...data, markdata]); + }); + mappingData; } const handleReSearch = () => { const params = {