diff --git a/pages/api/me/_get.ts b/pages/api/me/_get.ts index 40a518f9ae..1ae8d47d82 100644 --- a/pages/api/me/_get.ts +++ b/pages/api/me/_get.ts @@ -6,11 +6,14 @@ import { schemaUserReadPublic } from "@lib/validations/user"; import { User } from ".prisma/client"; -async function handler(req: NextApiRequest): Promise<{ error?: string; user?: Partial }> { +async function handler({ + userId, + prisma, +}: NextApiRequest): Promise<{ error?: string; user?: Partial }> { + const data = await prisma.user.findUniqueOrThrow({ where: { id: userId } }); if (!prisma) return { error: "Cant connect to database" }; - console.log(req); - if (!req.userId) return { error: "No user id found" }; - const data = await prisma.user.findUniqueOrThrow({ where: { id: req.userId } }); + + if (!userId) return { error: "No user id found" }; if (!data) return { error: "You need to pass apiKey" }; const user = schemaUserReadPublic.parse(data); return { user };