Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

97
Views
middleware function not being called

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 :)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!