Server

// routes/category
router.delete("/category/:slug", remove);
// controllers/category
export const remove = async (req, res) => {
  try {
    // console.log(req.params.slug);
    let category = await Category.findOneAndRemove({
      slug: req.params.slug,
    }).exec();
    res.json(category);
  } catch (err) {
    res.status(400).send("Delete failed");
    console.log(err);
  }
};

Client

// pages/admin/category/index
  const handleDelete = async (item) => {
    // console.log("delete", item);
    try {
      const { data } = await axios.delete(`/category/${item.slug}`);
      setCategories(categories.filter((cat) => cat.slug !== item.slug));
      toast.success("Category deleted");
    } catch (err) {
      console.log(err);
      toast.error("Category delete falied");
    }
  };