-1

I am creating a real estate site where I a using MERN stack, and by creating a component residency control and when I am testing my get API through thunder client, and in this line I am getting error.

// Function to get a specific document/residency
export const getResidency = asyncHandler(async (req, res) => {
  const { id } = req.params;

  try {
    const residency = await prisma.residency.findUnique({
      where: { id },
    });
    res.send(residency);
  } catch (error) {
    throw new Error(error.message);
  }
});

This is the error showing:

Error:

Invalid `prisma.residency.findUnique()` invocation:
Inconsistent column data: Malformed ObjectID: invalid character 'r' was found at index 1 in the provided hex string: "create".
    at file:///C:/Users/hp/Desktop/real-estate/server/controllers/resdCntrl.js:63:11

Expecting to run and get my residencies data but got 500 internal server error.

VLAZ
  • 26,331
  • 9
  • 49
  • 67

1 Answers1

0

You are sending the invalid ID to Mongo, as we can see from the error, it is the string "create"

Yuriy Vorobyov
  • 755
  • 4
  • 8