title: How to i fetch value of client.query in Node JS with PG?
body: <p>I am using node.js and make database connection with postgresql.
  My dbConfig.js look like :-</p>
  
  <pre><code>var pg = require('pg');
  var client  = new pg.Client({
      host:'myhoost',
      port:'5432',
      user:'myuser',
      password:'mypass',
      database:'mydb',
      ssl:true
  });
  client.connect();
  module.exports.myconnection = client;
  </code></pre>
  
  <p>my api.js file look like :- </p>
  
  <pre><code>var dbConnect = require('./dbConfig.js');
  var client = dbConnect.myconnection;
  var ser = function(value) {
      var query = "SELECT * FROM tbl_api WHERE apikey = '" + value + "'";
  
      client.query(query, function(err, result) {
          var res = true;
          if (err) {
              var res = false;
          } else {
              if (result.rowCount &gt; 0) {
                  res = true;
              } else {
                  res = false;
              }
          }
         return res;
      });
  };
  module.exports.checkAPI = ser;
  </code></pre>
  
  <p>my api.js look like:-</p>
  
  <pre><code>var express = require('express');
  var app = express();
  var apiCheck = require('./api.js');
  
  
  //APIKey Generator check api
  app.get('/apicheck/:apikey', function(request, response) {
      var value = request.params.apikey;
      var result = apiCheck.checkAPI(value);
      response.send(result);
  });
  </code></pre>
  
  <p>i want the res from client.query into the result variable. I found one same issue with <a href="https://github.com/mysqljs/mysql/issues/81" rel="nofollow noreferrer">mysqljs issue</a> but still i am not able to solve this doubt. </p>