Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

250
Views
why this code executes properly if and only if I call setTimeOut() function and the code doesn't do its aim exactly without callng it?
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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!