Web
Analytics
Express JS middleware with example - Tutorial

For Consultation : +91 9887575540

Stay Connected :

What is express middleware

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.

Major task of middleware

  • Execute any code.
  • Make changes to the request and the response objects.
  • End the request-response cycle.
  • Call the next middleware in the stack.




Example

  1. First Create new node application and create package.json , index.js and install node modules express and body- praser by following commands.

     
  2.  Write following code into index.js

     
  3. Run the program and start postman to see results

     

    Output

    express middlware output




Select your currency