I have a sequence of methods (get, post, put, delete), however the put method is wrong and I do not know how to solve it.
This is the snippet of code:
router.route('/')
.get((req, res) => res.status(200).send('Lista de Produtos'))
.post((req, res) => res.status(201).send(req.body))
.put(':id',(req, res, next) => {
const id = req.params.id;
res.status(201).send({
id: id,
item: req.body
});
})
.delete((req, res) => res.send('Remove Produtos'))
And this is the error:
Error: Route.put () requires a callback function but got a [object String]
I need the url in the url to send an id such as: link
The id would be 123 ..
and the answer would be { "id": "123", "item": { } }