Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

what is the meanof using next in nodejs

/*
Some people always write return next() is to ensure that the execution stops after triggering the callback.

If you don't do it, you risk triggering the callback a second time later, which usually has devastating results. 
*/

app.get('/users/:id?', function(req, res, next){
    var id = req.params.id;

    if(!id)
        return next();

    // do something
});

Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #meanof #nodejs
ADD COMMENT
Topic
Name
2+3 =