Help me please
async updateCategory(req) {
const {id} = req.params;
try {
let category = await Category.findByPk(id);
if (!req.body || !req.body.name || !req.body.slug || (req.body.use_in_menu != undefined && req.body.use_in_menu != null)) {
return {
status: 400,
message: "Dados invalidos."
}
}
if (!category) {
return {
status: 404,
message: "Categoria não encontrada."
}
}
await category.update(req.body)
return {
status: 204,
message: ""
}
} catch (error) {
return {
status: 500,
message: "Erro do servidor"
}
}
}
Is expected to return message 204 when i send a new payload, but it only return “400 invalid data”.