• HOME
    • PRODUCT
    • PRICING
    • ABOUT
    • COMMUNITY
    Menu
    • HOME
    • PRODUCT
    • PRICING
    • ABOUT
    • COMMUNITY
    Get in touch
    Get in touch
    Menu
    • HOME
    • PRODUCT
    • PRICING
    • ABOUT
    • COMMUNITY
    • Sign in
    • Start free trial
    • Get in touch
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Tags
    • Users
    • Groups
    • Documentation
      • Home
      • Read API
      • Write API
      • Plugin Development
    1. Home
    2. sad_nomad
    3. Posts
    S
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1
    • Best 0
    • Controversial 0
    • Groups 0

    Posts made by sad_nomad

    • node.js/express/mongodb wait for query results

      Facing the following problem: there is a simple web application (node.js/express/mongodb). user enters product id and the application shows price.

      function queryDb(var id) {
      // connect mongodb
      // find product price for id
      return price
      }

      app.post("/", function(req,res) {
      var id = req.body.id;
      var price = queryDb(id);
      // ---> wait here for the query to finish
      res.render('index', {price: price})
      })

      the app runs faster then the db query. how can I force the code to wait for queryDb() function to finish and return the price? I have tried callbacks, promises, async/await - always the same.

      posted in General Discussion
      S
      sad_nomad

    Get Started

    • Product
    • Pricing

    Resources

    • Demo Site
    • Answers
    • Docs
    • Bug Bounty

    Company

    • About
    • Blog
    • Contact
    Start Free Trial
    Github Facebook Instagram Twitter
    © 2014 – 2022 NodeBB, Inc. — Made in Canada.
    • Terms
    • Privacy
    • GDPR
    • DMCA
    • Contact
    Menu
    • Terms
    • Privacy
    • GDPR
    • DMCA
    • Contact