title: Function not returning pg-pool results
body: <p>I'm trying to use pg-pool to query a Postgresql database. And then export this data to a Node.js express rest API.</p>
  
  <p>Here's my exports function.</p>
  
  <pre><code>exports.getDashboard = function(req, response, next) {
    let returnData = fetchData();
    return response.status(200).json(returnData);
  };
  </code></pre>
  
  <p>Which calls fetchData();</p>
  
  <pre><code>fetchData = async function() {
      let returnData = [];
      returnData.languages = await getLatestLanguages();
      return returnData;
  };
  </code></pre>
  
  <p>Which calls getLatestLanguages()</p>
  
  <pre><code>getLatestLanguages = function() {
    pgPool.pool.query(
      'SELECT * FROM "WordLanguage" ORDER BY id DESC LIMIT 30 ;',
      (error, results) =&gt; {
        if (error) {
          throw error;
        }
        return results.rows;
      }
    );
  }
  </code></pre>
  
  <p>If i place a <code>console.log(results.rows)</code> before getLatestLanguages() returns results.rows, then I get the data logged to the console.</p>
  
  <p>However the object isn't being returned to fetchData. I tested this by logging the returnData to console before it is returned to exports.getDashboard();</p>
  
  <p>I believe my problem is something to do with the async nature of pg-pool so I tried making my function async with an await but that didn't help.</p>
  
  <p>What am I doing wrong?</p>