我的代码如下…我应该能够键入文章/DOM并能够获得标题DOM的所有对象,但相反,我得到一个类型错误,即ArticleTitle未定义。请帮助!
app.route("/articles/:articleTitle").get( function(res,req) {
Article.findOne({title: req.params.articleTitle}, function(err,foundArticle){
if (foundArticle){
res.send(foundArticle)
} else{res.send("No article matching that title was found!")}
});
}
)
app.listen(3000, function() {
console.log("Server started on port 3000");
});
first argument
应该是req
,second argument
应该是res
,所以这样做:
app.route("/articles/:articleTitle").get( function(req, res) {})