写我的快递应用程序我遇到了这个错误,我不确定该怎么办?使用快递4.14,我不知道该怎么做,它寻找一个状态,但我目前没有给它一个状态。观看他们的文档的事件,他们没有给出他们的示例路线的状态。
express deprecated res.redirect(url, status): Use res.redirect(status, url)
这是我的代码:
router.post("/event", isLoggedIn, function (req,res){
// get data from form and add to events array
var title = req.body.title;
var date = req.body.date;
var description = req.body.description;
var venue = req.body.venue;
var photo = req.body.photo;
var category = req.body.category;
//get user data to save to the user
var owner = {
id: req.user._id,
username: req.user.username
}
var newEvent = {category: category, title: title, date: date, description: description, venue: venue, photos:{link: photo,date: date}, owner: owner};
Event.create(newEvent, function(err, event){
if(err){
console.log(err)
} else {
//This takes the event owner ID and saves it into the model
event.owner.id = req.user._id;
//This takes the event username and saves it into the model
event.owner.username = req.user.username;
event.save();
console.log(event);
res.render('events',{events: event}); }
})
})
答案 0 :(得分:1)
在我的项目中,我总是这样做:
function(req, res) {
res.status(301).redirect('http://google.com')
}
答案 1 :(得分:0)
通过更新 atom 包解决了我的问题,您可以检查编辑器包中是否有任何更新。