使用express js 返回(发送)int

rap*_*2-h 2 javascript node.js express

如果我用 Express 执行此操作,则会失败:

res.send(13245)
Run Code Online (Sandbox Code Playgroud)

它说:

表达已弃用的 res.send(status):使用 res.sendStatus(status) 代替 src/x.js:38:9 (节点:25549) UnhandledPromiseRejectionWarning:RangeError [ERR_HTTP_INVALID_STATUS_CODE]:无效状态代码:13245

这是因为它认为13245可能是一个状态代码。我还是想回去13245,有什么办法吗?

rap*_*2-h 5

您必须返回一个字符串(请参阅http://expressjs.com/en/api.html#res.send):

res.send('13245')
Run Code Online (Sandbox Code Playgroud)