Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- exports.create = (req, res) => {
- if(!req.body.name) {
- return res.status(400).send({
- message: "Fields can not be empty"
- });
- }
- // Create a Category
- const category = new Category({
- name: req.body.name,
- details: req.body.details
- });
- // Save Category in the database
- category.save()
- .then(data => {
- res.send(data);
- }).catch(err => {
- res.status(500).send({
- message: err.message || "Something went wrong."
- });
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment