What do you understand by middleware? How can you use middleware in Node JS?
Middleware functions are those functions having access to the request object (req), the response object (res), and also the next function in an application's request-response cycle. The following function is basically a function in the Express router, when invoked, executes the middleware which is succeeding in the current middleware.
Middlewares can perform the following tasks:
- Execute any type of code
- Making changes to the request and response objects
- We are ending the request-response cycle.
- Cleaning the next middleware in the stack
BY Best Interview Question ON 25 Jun 2020