title: Promise.all in JavaScript: How to get resolve value for all promises?
body: <p>I wrote the following node.js file: </p>
  
  <pre><code>var csv = require('csv-parser');
  var fs = require('fs')
  var Promise = require('bluebird');
  var filename = "devices.csv";
  var devices;
  
  Promise.all(read_csv_file("devices.csv"), read_csv_file("bugs.csv")).then(function(result) {
      console.log(result);
  });
  
  
  function read_csv_file(filename) {
      return new Promise(function (resolve, reject) {
              var result = []
              fs.createReadStream(filename)
                  .pipe(csv())
                  .on('data', function (data) {
                      result.push(data)
                  }).on('end', function () {
                  resolve(result);
              });
      })
  }
  </code></pre>
  
  <p>As you can see, I use <code>Promise.all</code> in order to wait for both operations of reading the csv files. I don't understand why but when I run the code the line <code>'console.log(result)'</code> is not committed. </p>
  
  <p>My second question is I want that the callback function of <code>Promise.all.then()</code> accepts two different variables, while each one of them is the result of the relevant promise. </p>