From 3945a4729f08f2093e660fa0f6ddeb00e4a9f3ad Mon Sep 17 00:00:00 2001 From: Ram <74136560+Ram-143-sai@users.noreply.github.com> Date: Sun, 9 Apr 2023 16:51:49 +0530 Subject: [PATCH] Fixed issue #30 With respect to the issue raised https://github.com/academind/node-restful-api-tutorial/issues/30. due to initialization of constructor objectId without new its throwing error. Add the changes now which working fine. --- api/routes/orders.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/routes/orders.js b/api/routes/orders.js index aadce9b..74cc984 100644 --- a/api/routes/orders.js +++ b/api/routes/orders.js @@ -42,7 +42,7 @@ router.post("/", (req, res, next) => { }); } const order = new Order({ - _id: mongoose.Types.ObjectId(), + _id: new mongoose.Types.ObjectId(), quantity: req.body.quantity, product: req.body.productId });