diff --git a/src/app/(app)/page.tsx b/src/app/(app)/page.tsx index f4142ff..f1277b2 100644 --- a/src/app/(app)/page.tsx +++ b/src/app/(app)/page.tsx @@ -9,7 +9,7 @@ function Mobile() { const [friendsPostsData, setFriendsPosts] = useState([]); function getFriendsPosts(friendId: any) { - fetch(`/api/users/${friendId}/posts`) + fetch(`/api/user/${friendId}/posts`) .then((res) => res.json()) .then((data) => { if (data.posts) { @@ -25,12 +25,14 @@ function Mobile() { // Fetch friends' posts useEffect(() => { - if (isAuthenticated && session?.friends) { - let friendsIds = session.friends.map((friend: any) => friend.id); + if (isAuthenticated && session) { + let friendsIds = session.friends.map((friend: any) => friend); + + console.log("Friends IDs:", friendsIds); // use /api/users/:id to get friend data friendsIds.forEach((friendId: any) => { - fetch(`/api/users/${friendId}`) + fetch(`/api/user/${friendId}`) .then((res) => res.json()) .then((data) => { if (data.user) { @@ -44,7 +46,7 @@ function Mobile() { }); }); } - }, [isAuthenticated, session?.friends]); + }, [isAuthenticated, session]); return (
@@ -107,6 +109,6 @@ function Web() { export default function Home() { const { isMobile, isSafari } = useDevice(); - if (isMobile && isSafari) return ; - else return ; + if (isMobile && isSafari) return Mobile(); + else return Mobile(); }