I am trying to write a PUT request for my API. I'm using restify to build the API. I keep getting the errors, could you please help?
//PUT (Update) Items
app.put('/items/:item_id', function(req, res){
var query = Item.where({_id: req.params.item_id});
query.findById(req.params.id, function (err, items) {
item.name = req.body.name;
item.description = req.body.description;
item.url = req.body.url;
req.item.save(function (err) {
if (!err) {
console.log("updated");
} else {
console.log(err);
}
res.send(204, item);
});
});
I tried testing it using POSTMAN client and I get this error
{
"code": "InternalError",
"message": "Object #<Query> has no method 'findById'"
}
Thanks.