Fix the bug

At the moment, when you compose a post and redirect to the root route, sometimes the post is not yet saved and doesn’t show up on the home page.

Goal: Add a callback to the save method to only redirect to the home page once save is complete with no errors.

Scroll down if you need a hint 👇


























  • You’ll need to add a call back to the mongoose save() method.


 post.save(function(err){

   if (!err){

     res.redirect("/");

   }

 });


Complete and Continue  
Discussion

0 comments