文件名script.js.
在运行CRUD应用程序时,我遇到了这个错误。在这个特定的代码行出现错误,有人能提出一些解决方案吗?
如果你想完整地查看代码,请告诉我,我会在评论中发布它
错误
"express deprecated res.send(status, body): Use res.status(status).send(body) instead script.js:18:5
RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: <h2 style="font-family: Malgun Gothic; color: midnightblue ">Welcome to Edureka Node.js MongoDB Tutorial!!</h2>
代码
//Create a welcome message and direct them to the main page
app.get('/', (req, res) => {
res.send(
'<h2 style="font-family: Malgun Gothic; color: midnightblue ">Welcome to Edureka Node.js MongoDB
Tutorial!!</h2>'
,'Click Here to go to <b> <a href="/course">Course Page</a> </b>');
});
app.use(bodyparser.json());
像这样改变它的工作
res.status(200).send(
'<h2 style="font-family: Malgun Gothic; color: midnightblue ">Welcome to Edureka
Node.js MongoDB Tutorial!!</h2>'
,'Click Here to go to <b> <a href="/course">Course Page</a> </b>');
});