text: const router = require('express').Router();
  const { Category, Product } = require('../../models');
  
  // The `/api/categories` endpoint
  
  router.get('/', async (req, res) => {
    // find all categories
    // be sure to include its associated Products
    try {
      const categoryData = await Category.findAll({
        include: [{ model: Product }]
      })
      res.status(200).json(categoryData);
    } catch (err) {
      res.status(500).json(err);
    }
  });
  
  router.get('/:id', async (req, res) => {
    // find one category by its `id` value
    // be sure to include its associated Products
    try {
      const categoryData = await Category.findByPk(req.params.id, {
        include: [{ model: Product }]
      });
  
      if (!categoryData) {
        res.status(404).json({ message: "No category found for that id." });
      }
      res.status(200).json(categoryData);
    } catch (err) {
      console.log(err);
      res.status(500).json(err);
    }
  });
  
  router.post('/', (req, res) => {
    // create a new category
    Category.create(req.body)
    .then((newCategory) =>{
      res.json(newCategory)
    })
    .catch((err) => {
      res.json(err)
    })
  });
  
  router.put('/:id', async (req, res) => {
    // update a category by its `id` value
    console.log(req);
    try {
      const updateCategory = await Category.update(req.body, {
        where: {
          id: req.params.id
        }
      });
      console.log(updateCategory);
      res.status(200).json(updateCategory);
    }
    catch (err) {
      res.sendStatus(00).json(err);
    }
  });
  
  router.delete('/:id', (req, res) => {
    // delete a category by its `id` value
    Category.destroy({
      where: {
        id: req.params.id
      }
    })
    .then((deletedCategory) => {
      res.json(deletedCategory)
    })
    .catch(err => res.status(400).json(err));
  });
  
  module.exports = router;