title: How to Async combine multiple JSON arrays into 1 with Node.js javascript
body: <p>I'm using NodeJS and Async to perform multiple select queries. Therefore I want to populate the <code>collection</code> array with <code>firstqueryarray</code> and <code>secondqueryarray</code>.</p>
  
  <p>How can I combine the first and second response into one array?</p>
  
  <pre><code>exports.relations = function (req, res) {
  
      var collection = [];
  
      async.parallel([
          function () {
              var firstqueryarray= [];
              connection.query(query1, function (err, rows, fields) {
                  if (err) throw err;
                  for (var i in rows) {
                      firstqueryarray.push({
                          name: rows[i].name,
                          email: rows[i].email
                      });
                  }
                  res.json({
                      firstqueryarray: firstqueryarray
                  });
              });
  
          }
  
      , function () {
              var secondqueryarray= [];
              connection.query(query2, function (err, rows, fields) {
                  if (err) throw err;
  
                  for (var i in rows) {
                      secondqueryarray.push({
                          name: rows[i].name,
                          email: rows[i].email
                      });
                  }
                  res.json({
                      secondqueryarray: secondqueryarray
                  });
              });
          }
        ]
      )
  };
  </code></pre>