Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- exports.update = (req, res) => {
- if(!req.body.name) {
- return res.status(400).send({
- message: "Fields can not be empty"
- });
- }
- // Find category and update it with the request body
- Category.findByIdAndUpdate(req.params.categoryId, {
- name: req.body.name,
- details: req.body.details
- }, {new: true})
- .then(category => {
- if(!category) {
- return res.status(404).send({
- message: "Category does not exist"
- });
- }
- res.send(category);
- }).catch(err => {
- return res.status(500).send({
- message: "Something went wrong"
- });
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment