Middleware functions are functions that have access to the request object (
req), the response object (
res), and the
next function in the application’s request-response cycle. The
next function is a function in the Express router which, when invoked, executes the middleware succeeding the current middleware.
- Here first called logger function because it called before the api.
2. Here, the logger function is not called because it placed after the api and there is no next exist in api.
3. Here we have added next in api , therefor the logger function is called. Thats what next do, if there is any middleware after api and we want to call it so we use next so if there is any middleware function then it will run.
4. Here, if we pass false in params then it will show no Auth.