title: Do not wait for mysql database result in node js
body: <p>I tried to get result using mysql database query from called function but do not wait for result in called function. Following is my code for users.js file. I got result in <strong>getBankDetail</strong> function but do not get result in <strong>users</strong> function.</p>
  
  <pre><code>var db = require("../db/mysqlconnection");
  
  function users(app){
   app.get("/users",async function(req, res, next){
      let bankDetail = await getBankDetail();
      console.log("bankDetail",bankDetail); //Here I do not got result
      return res.send(bankDetail);
   });
  }
  
  
  async function getBankDetail(){
      db.getConnection(async function(err, connection) {
        if (err) throw err; // not connected!
  
       await connection.query('SELECT * FROM bank', function (error, results, fields) {
          connection.release();
  
          if (error) throw error;
          console.log("bank result",results);  //Here I got result
          return results;
        });
      });
  }
  
  module.exports = users;
  </code></pre>
  
  <p>My Question is why do not wait for result in called function? I also used async/await functionality.</p>