title: Node.Js: Async return gives undefined
body: <p>I'm trying to make a function which returns the user's balance. However, the function returns <code>undefined</code>. I've checked all the solutions on stackoverflow but I wasn't able to find a solution.</p>
  <p>Return func</p>
  <pre><code>    async function checkBal(username) {
          db.getConnection(async (err, connection) =&gt; {
              if (err) throw (err)
              let queryBal = `SELECT balance FROM user WHERE username = &quot;${username}&quot;;`
              connection.query(queryBal, async (err, result) =&gt; {
                  if (err) throw (err)
                  if (result.length != 0) {
                      const data = result[0].balance
                      return data               
  </code></pre>
  <p>Function from which I'm calling</p>
  <pre><code>    app.post(&quot;/api/bet&quot;, urlencodedParser, async function(req, res){ 
          ssn = req.session;
          if (ssn.username) {
              balance = await checkBal(ssn.username)
              console.log(balance)
  </code></pre>