#Nextjs URL Parameters Prisma

3 messages · Page 1 of 1 (latest)

odd crypt
#

Hello đź‘‹

It looks like the issue happens because you are not returning any response from your handler.
Can you try something like this?

import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

export default async function handler(req, res) {
  const { key } = req.query;
  try {
    const validation = await prisma.Reservation.findUnique({
      where: {
        id: key,
      },
    });
    console.log(validation);
    if (validation) {
      res.status(200).json({ validation });  // send the validation as the response
    } else {
      res.status(404).json({ error: "No reservation found with this key." });
    }
  } catch (err) {
    res.status(500).json({ error: err });
  }
}

slim hinge
# fervent plover thanks!

In the future, no need to delete your message. That way if people have the same problem they can find your thread! 🙂