📜  在 nodejs 中使用 next 是什么意思 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:21.743000             🧑  作者: Mango

代码示例1
/*
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
});