Do I need to call next() after res.send()?

后端 未结 2 2026
遇见更好的自我
遇见更好的自我 2021-02-18 22:03

If I called res.send(), but didn\'t call next():

  1. Any middleware after this middleware won\'t be executed.
  2. If this middleware is
2条回答
  •  粉色の甜心
    2021-02-18 23:05

    Simply

    1. All the middlewares use same request and response objects, so if you send the response via any middleware all next middlewares will be skipped
    2. You can still execute further operations by calling next(); but you can't do res.send() or res.json() further

提交回复
热议问题