Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Middleware in Express JS

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 226
    Comment on it

    Middleware is the core idea of Express.js used behind processing the request and routing. By seeing how middleware functions, you can make more maintainble applications with less code. The minute a solicitation is gotten by an Express.js application, it triggers different capacities alluded to as middleware.

    What is middleware?

    Middleware is any number of capacities that are used by the Express.js steering layer before your last demand handler is, and in this way sits in the center between a crude solicitation and the last proposed course. We frequently allude to these capacities as the middleware stack since they are constantly conjured in the request they are included.

    var app = express();
    
    app.get('/', function(req, res) {
      res.send('Hello World!');
    });
    
    app.get('/help', function(req, res) {
      res.send('Nope.. nothing to see here');
    });
    

    Middleware also can be defined as a function that used the request object (req), the response object (res), and the next middleware in the applications request-response cycle. Same is also used in above example code.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: