import prismadb from '@/lib/prismadb'; import { NextApiRequest,NextApiResponse } from "next"; import serverAuth from '@/lib/serverAuth'; export default async function handler(res: NextApiResponse,req:NextApiRequest) { if(req.method !== "GET"){ return res.status(405).end() } try { const { currentUser } = await serverAuth(req); const favoritesMovie = await prismadb.movie.findMany({ where: { id: { in: currentUser?.favoriteIds, } } }) return res.status(200).json(favoritesMovie); }catch(error){ console.log(error) return res.status(400).end() } }