Day 3 of my full stack project

The day of error and debugging :-(

Today was all about debugging the error which I got

I was testing the code such that just the user with the role admin should be able to see the products but for some reason, it's showing an error which I'm not quite sure how to fix it
I referred to the resources I'm using and I didn't see any mistakes so ya don't know what to do I guess I gotta debug more


const express = require("express");
const { getAllProducts,createProduct, updateProduct, deleteProduct, getProductDetails } = require("../controllers/productController");
const { isAuthenticatedUser,authorizeRoles } = require("../middleware/auth");

const router = express.Router();


router.route("/products").get(getAllProducts);

router.route("/products/new").post(  isAuthenticatedUser ,authorizeRoles("admin") ,createProduct);

router.route("/products/:id").put( isAuthenticatedUser ,authorizeRoles("admin"),updateProduct).delete( isAuthenticatedUser ,authorizeRoles("admin"),deleteProduct).get(getProductDetails);


module.exports = route

So here the authorizedRoles method you can see is supposed to add/update/delete products when its accessed by admin only

which you can see below

exports.authorizeRoles = (...roles) => {
  return (req, res, next) => {
    if (!roles.includes(req.user.role)) {
      return next(
        new ErrorHander(
          `Role: ${req.user.role} is not allowed to access this resouce `,
          403
        )
      );
    }

    next();
  };
};

But when I'm trying its showing


Errors are part of the project and they actually help a lot so I hope I find the error as soon as possible and get it fixed asap!