Home > front end >  Using Middleware in node.js and MVC Routes
Using Middleware in node.js and MVC Routes

Time:10-25

I'm having problems deploying a middleware in the routes of my application, basically, its structure is as shown in the following screenshots.

My middleware:

enter image description here

My Controller:

enter image description here

My routes.js

enter image description here

However, when I try to add the middleware to my route there is an error in the application, I am adding the middleware as follows: enter image description here

The error returned when starting the application is: Error: Route.get() requires a callback function but got a [object Object]

My application doesn't have the (req, res) right there after the route declaration, if so, I would just add the middleware first, however, see that my application calls the list method inside the Class Unit directly in the route declaration. How do I increment Middleware there?

Thanks

CodePudding user response:

You missed exporting middleware function.

  • Related