Reputation: 5
i have this middleware function that supposed to create new product doc into the database:
exports.postAddProduct = (req, res, next)
the function is used in this route:
router.post(
'/add-product',
productValidation.addProductValidation,//(a middleware function that validate user input)
isAuth,//(a middleware function that validate the user is logged in
adminController.postAddProduct
);
the request is triggerd by an ejs form. but still the middleware is not being called. i will appreciate any help :)
Upvotes: 0
Views: 528
Reputation: 837
i can only assume in this case :
An error is triggered during productValidation.addProductValidation
or isAuth
, the code would stop and throw a error(or be send to the error handling middleware)
you forgot to add next()
at the end of of three middlewares
, it's easy to notice if you inspect the page using F12
and look inside the network
tab for the request that it's being called when the form is submited
Upvotes: 1