title: Pg-Promise Not Returning Results With EJS
body: <p>I'm having trouble trying to get the Postgres data using Pg-Promise using this previous Stackoverflow question: <a href="https://stackoverflow.com/questions/44566999/get-the-result-of-postgres-query-as-variable-in-nodejs">Get the result of postgres-query as variable in nodejs</a>. </p>
  
  <p>If I do this code, the webpage just keeps loading and hangs, finally spitting out an EJS error "<strong>row_result is not defined</strong>". I just want to store the SELECT query results in a variable so I can use it outside of the db.task block. Any suggestions?</p>
  
  <pre><code>var row_result = "";
  
  db.task(function * (t) {
      let a= yield t.query("SELECT * FROM public.applications;");
      return {a};
  })
  
  .then(data =&gt; {
  row_result = JSON.parse(JSON.stringify(a));
  res.render('/applications', {row_result:row_result});
  })
  
  .catch(error =&gt; {
    console.log('error');
  })
  
  .finally(() =&gt; {
      pgp.end();
  });
  </code></pre>
  
  <p>In addition, is there any way to do this?</p>
  
  <pre><code>var row_result = "";
  
  db.task(function * (t) {
      let a= yield t.query("SELECT * FROM public.applications;");
      return {a};
  })
  
  .then(data =&gt; {
  row_result = JSON.parse(JSON.stringify(a));
  })
  
  .catch(error =&gt; {
    console.log('error');
  })
  
  .finally(() =&gt; {
      pgp.end();
  });
  
  res.render('/applications', {row_result:row_result});
  </code></pre>