For context here is my handler:
export async function PUT(request: NextRequest, { params: { id } }: Props) {
const body = await request.json();
const validation = schema.safeParse(body);
if (!validation.success) {
return NextResponse.json(validation.error.errors, { status: 400 });
}
const user = await prisma.user.findUnique({
where: { id: +id },
});
if (!user) {
return NextResponse.json({ error: "User not found." }, { status: 404 });
}
const updatedUser = prisma.user.update({
where: { id: +id },
data: { name: body.name, email: body.email },
});
return NextResponse.json(updatedUser, { status: 200 });
}
I send the request on Postman and I’m just getting an empty object in the response. I can’t seem to figure out what I did wrong. Any help is appreciated! Thank you!