node-express error : express deprecated res.send(status): Use res.sendStatus(status) instead

前端 未结 7 899
甜味超标
甜味超标 2020-12-09 09:22

I am trying to send an integer via response.send() but I keep getting this error

express deprecated res.send(status): Use res.sendStatus

相关标签:
7条回答
  • 2020-12-09 09:47

    Its deprecated Express 5 no longer supports the signature like -

    res.json(200, {
       result: result
    });
    

    Instead, use a method like this, means you only need to change the format of sending responses.

    res.status(status).json(obj)
    

    Example -

    res.status(200).json({'success' : true, 'result': 'result'})
    
    0 讨论(0)
提交回复
热议问题