【发布时间】:2020-02-28 10:22:15
【问题描述】:
每当我删除我的订单并尝试使用相同的 id 再次获取时 它返回一个正确的响应(未找到订单),但在控制台中它返回一个错误
router.delete("/:orderID", (req, res, next) => {
const id = req.params.orderID;
Orders.deleteOne({ _id: id })
.exec()
.then(result => {
if (!result) {
res.status(404).json({
message: "there is no such Order to Delete, Kindly Check Order ID",
fetchAll: "http://localhost:3000/orders/"
});
}
res.status(200).json({
message: "Order Deleted Successfully",
request: {
type: "POST",
url: "http://localhost:3000/orders/",
body: {
productID: "Id of the Product",
quantity: "Total Quantity of the Product"
}
}
});
})
.catch(err => {
console.log(err);
res.status(500).json({
error: err
});
});
});
【问题讨论】:
标签: node.js mongodb express npm mongoose