title: Javascript - Returning data from const-declared arrow function
body: <p>I've a function that makes a simple pgsql query which I'd like returned to the const variable it's declared in, so I can access it in other parts of the code.</p>
  <pre><code>const Id = client.query(idQuery, (err, result) =&gt; {
      if(err) {
          console.log(err);
      }
      const Data = result.rows;
      if(Data == undefined) {
          console.log(&quot;Running query ...&quot;);
      } else {
          console.log(&quot;Done.&quot;);
      }
      return Data;
  })
  </code></pre>
  <p>Yet, if I try to assign its value like so: <code>const testVar = Id</code>, the value is always <code>undefined</code>. The same is true if I <code>console.log(Id)</code>. There's probably something very simple that I'm glancing over, but I've declared other functions similarly with successful output.</p>