Whenever I try to update an object from the genres array using the code below, nothing happens. I get a 200 status code but the object remains the same with no updated value. where could I be going wrong? I'll greatly appreciate all the help I can get.
const schema = Joi.object({
name: Joi.string().min(3).required()
});
app.put('/api/genres/:id', (req, res) => {
const genre = genres.find(g => g.id === parseInt(req.params.id))
if(!genre) return res.status(404).send("Not Found")
res.send(genre)
const {error, value} = schema.validate(req.body)
if (error) {
console.log(error);
return res.status(400).send("Bad Request");
};
genre.name = req.body.name;
res.send(genre)
})
await genre.save();before you return anything ...?