0
app.get("/", function(req, res) {
  var posts = [];
  Post.find({}, function(err, arr) {
    if (err) {
      console.log("error");
    } else {
      posts = arr;
    }
  });
  // res.render("home",{par:par,posts:posts})
  setTimeout(function() {
    res.render("home", {
      par: par,
      posts: posts
    })
  }, 300);
});

the code only does its aim when using setTimeout function even if the function inside the setTimeout is the same commented function that doesnt work properly

0 Answers0