Express.js Routing error: Can't set headers after they are sent

前端 未结 6 2087
情歌与酒
情歌与酒 2020-12-01 05:35

I\'m not really sure why I\'m getting this error. It\'s a simple API built on express.js to be able to add and remove posts. The error occurs when I trigger the delete route

6条回答
  •  一整个雨季
    2020-12-01 05:58

    You are using res.send() or res.json() twice in the same request

    this send the headers first, followed by body of the response and then headers again. req.next is usually not a function, next is rather passed as a third argument of the middleware. Use that if you want to drop to the next middleware. (assuming you are using Express framework)

提交回复
热议问题