'In CURD operation Update Not work, PUT https://pacific-gorge-29321.herokuapp.com/item/627687994c38508f7b5f8e12 404 (Not Found)
In CURD operation Update Not work, show this error: PUT https://pacific-gorge-29321.herokuapp.com/item/627687994c38508f7b5f8e12 404 (Not Found) Backend code:
// update data
app.put('/item/:id', async (req, res) => {
const item = req.body;
const id = req.params.id;
console.log(item, id);
const filter = {_id: ObjectId(id)};
const options = {update: true};
const updateDoc = {
$set: {
...item,
},
};
const result = await itemCollection.updateOne(
filter,
updateDoc,
options
);
res.send(result)
})
Frontend Code:
const deliveredItem = id => {
const proceed = window.confirm("Are You Sure?");
if (proceed) {
const url = `https://pacific-gorge-29321.herokuapp.com/item/${id}`
fetch(url, {
method: 'PUT'
})
.then(res => res.json())
.then(data => {
console.log(data);
})
}
}
ERROR:
PUT https://pacific-gorge-29321.herokuapp.com/item/627687994c38508f7b5f8e12 404 (Not Found)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
