[PUT 404 (NotFound) ][1]
Client-side code
const confirmDeliver = (event) => {
const newQuantity = inventory.quantity - 1;
const updateQuantity = { newQuantity };
const url = `http://localhost:5000/inventory/${inventoryId}`;
fetch(url, {
method: "PUT",
headers: {
"content-type": "application/json",
},
body: JSON.stringify(updateQuantity),
})
.then((response) => response.json())
.then((data) => console.log(data)); };
Server-side code
app.put("inventory/:id", async (req, res) => {
const id = req.params.id;
const updatedQuantity = req.body;
const filter = { _id: ObjectId(id) };
const options = { upsert: true };
const updatedDoc = {
$set: {
quantity: updatedQuantity.quantity,
},
};
const result = await inventoryCollection.updateOne(
filter,
options,
updatedDoc
);
res.send(result);
});
Can anyone tell me why I am getting this error? How can I solve this?