title: PSQL nodejs variable undefined
body: <p>I have a problem with my function to get all articles from my database.</p>
  
  <p>Articles database:
  id |  title   | price |  description</p>
  
  <p>images database: 
  id | articleid | name</p>
  
  <p>When I log the data 'articles' it's undefined.</p>
  
  <pre><code>client.query('SELECT * FROM articles', function (err, result) {
          if (err) throw err;
  
          if (result.rowCount != 0) {
              var articles = [];
              result.rows.forEach(function (entry) {
                  client.query('SELECT name FROM images WHERE articleid = $1', [entry.id], function (err, result) {
                      if (err) throw err;
  
                      var article = [];
                      var images = [];
  
                      result.rows.forEach(function (entry) {
                          images.push(entry.name);
                      });
  
                      article = entry;
                      article.images = images;
  
                      articles.push(article);
  
                  });
              });
              console.log(articles);
              res.send(articles);
          }
  
          res.send();
      });
  </code></pre>