What is the difference between next() and next('route') in an expressjs app.VERB call?

后端 未结 2 1377
星月不相逢
星月不相逢 2021-01-30 12:59

The docs read:

The app.VERB() methods provide the routing functionality in Express, where VERB is one of the HTTP verbs, such as app.post(). Multiple

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-30 13:28

    I hated it when I answer my own question 5 minutes later. next('route') is when using route middleware. So if you have:

    app.get('/forum/:fid', middleware1, middleware2, function(){
      // ...
    })
    

    the function middleware1() has a chance to call next() to pass control to middleware2, or next('route') to pass control to the next matching route altogether.

提交回复
热议问题