title: How to use the bluebird concurrency option for the map function
body: <p>I am trying to use bluebird's map function with the built-in concurrency control.</p>
  
  <p>I want to retrieve a list of names, then make a number of POST requests for each name. For example, I want to make a request for each name for each day of the week. However, I need to throttle the number of concurrent POST requests because the intended server has rate limits.</p>
  
  <pre><code>function getNames() {
      //Open mongodb connection
      //Get collection and array of names
      //return array of names in a promise 
  }
  
  function createDatesArray() {
      //Create an array of rates
      //return array of dates in a promise
      //Ex. return Promise.resolve(datesArray);
  }
  
  getNames().map(function (name) {
      return createDatesArray().map(function (date) {
          return requestData(date, name);
      }, {concurrency: 5});
  }).then(function () {
  //do something
  });
  </code></pre>
  
  <p>Is this the correct way to use bluebird's concurrency?</p>
  
  <p>The documentation link is here <a href="http://bluebirdjs.com/docs/api/promise.map.html" rel="noreferrer">bluebird documentation</a>.</p>