title: Node JS : Select json data after postgres query
body: <p>I am trying to get some Data from my postgres Database. But when I try to get the json data from the postgres result, I always receive an error.</p>
  
  <p>Here is my Node JS code:</p>
  
  <pre><code>pg.connect(connectionString, function(err, client, done) {
  var pubKey;
  var query1 = client.query("SELECT * FROM users where userid=($1) ORDER BY userid ASC;", [umschlagInnen.sourceUserID]);
  
      query1.on('row', function(row) {
          pubKey = row;
      });
  
      console.log(pubkey.pubkey);
  }
  </code></pre>
  
  <p>umschlagInnen.sourceUserID is "2"</p>
  
  <p>My postures-table for "users" looks like this:</p>
  
  <pre><code>users(userID int PRIMARY KEY, saltMaster varchar(255) not null, privKeyEnc varchar(2048) not null, pubKey VARCHAR(2048) not null)
  </code></pre>
  
  <p>The error:</p>
  
  <pre><code>ReferenceError: pubkey is not defined
  </code></pre>
  
  <p>Can you find any of my Mistakes?</p>