|
1 | 1 | import { GetServerSideProps, GetServerSidePropsContext } from "next"; |
2 | | -import { getFavorites } from "@/lib/api/link"; |
| 2 | +import { proxy } from "@/lib/api/axiosInstanceApi"; |
3 | 3 | import LinkCard from "@/components/LinkCard"; |
4 | 4 | import CardsLayout from "@/components/Layout/CardsLayout"; |
5 | 5 | import Container from "@/components/Layout/Container"; |
@@ -28,37 +28,21 @@ export const getServerSideProps: GetServerSideProps = async ( |
28 | 28 | const cookies = req.headers.cookie || ""; |
29 | 29 |
|
30 | 30 | try { |
31 | | - const res = await getFavorites({ |
| 31 | + const res = await proxy.get("/api/favorites", { |
32 | 32 | headers: { |
33 | 33 | Cookie: cookies, // 쿠키를 그대로 포함시킴 |
34 | 34 | }, |
35 | 35 | }); |
36 | | - return { props: { favoriteList: res.list || [] } }; |
| 36 | + |
| 37 | + const { list, totalCount } = res.data || { list: [], totalCount: 0 }; |
| 38 | + return { props: { favoriteList: list, totalCount } }; |
37 | 39 | } catch (error) { |
38 | 40 | console.error("서버사이드에러", error); |
39 | | - return { props: { favoriteList: [] } }; |
| 41 | + return { props: { favoriteList: [], totalCount: 0 } }; |
40 | 42 | } |
41 | 43 | }; |
42 | 44 |
|
43 | | -const FavoritePage = ({ favoriteList }: FavoriteProps) => { |
44 | | - // 임시 보류 |
45 | | - // const [favoriteList, setFavoriteList] = useState<FavoriteDataType[]>([]); |
46 | | - |
47 | | - // useEffect(() => { |
48 | | - // const fetchFavorites = async () => { |
49 | | - // try { |
50 | | - // const data = await getFavorites(); |
51 | | - // if (data) { |
52 | | - // setFavoriteList(data.list); |
53 | | - // } |
54 | | - // } catch (err) { |
55 | | - // console.error(err); |
56 | | - // } |
57 | | - // }; |
58 | | - |
59 | | - // fetchFavorites(); |
60 | | - // }, []); |
61 | | - |
| 45 | +const FavoritePage = ({ favoriteList, totalCount }: FavoriteProps) => { |
62 | 46 | return ( |
63 | 47 | <> |
64 | 48 | <div className="page-title pt-[10px] md:pt-5 pb-10 md:pb-[60px] bg-gray100 text-center"> |
|
0 commit comments