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

后端 未结 2 2021
遇见更好的自我
遇见更好的自我 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 22:47

    You don't need to call next() to finish sending the response. res.send() or res.json() should end all writing to the response stream and send the response.

    However, you absolutely can call next() if you want to do further processing after the response is sent, just make sure you don't write to the response stream after you call res.send().

提交回复
热议问题