Thursday, 25 May 2017

Express deprecated res.redirect(url, status): Use res.redirect(status, url) instead

I am trying to send a post request and i get this error Express deprecated res.redirect(url, status): Use res.redirect(status, url) instead

app.post("/blogs/:id/likes", isLoggedIn,function(req, res){
//lookup Campground using ID
Blog.findById(req.params.id, function(err, blog){
   if(err){
       console.log(err);
       res.redirect("/blogs");
   } else {
           //add username and id to comment
     var userIndex = blog.likes.indexOf(req.user._id);
if (userIndex > -1) {
blog.likes.splice(userIndex, 1);
} else {
blog.likes.push(req.user);
}
blog.save();


           res.redirect('/blogs/' + blog._id, {blog_id: req.params.id});


   }
});
}); 



via fanffis theologiths

No comments:

Post a Comment