Module to return the result of a promise
<p>I have a bunch of async calls I want to put in a module and use the result in another. But it seems there is no way to use a return value in an async call with promise/callback.</p>

<pre><code>module.exports = function () {
  Promise.all(data_promises).then(/* do stuff with data */)
  // return data ?
}
</code></pre>

<p>In another module:</p>

<pre><code>var getData = require('async-module')
var data = getData()
</code></pre>

<p>Is it even possible with separate modules?</p>

<hr>

<p>The actual code:</p>

<pre><code>module.exports = function () {

  agentsSheet.useServiceAccountAuthAsync(creds).then(function(){

    var data_promises = priceCols.map(function (col) {
      return agentsSheet.getCellsAsync(1, {
        'min-row': 2,
        'max-row': 30,
        'min-col': col,
        'max-col': col,
        'return-empty': false
      })
    })

    Promise.all(data_promises).then(function (data) {
      var rawData = _.flattenDeep(data)
      var priceOptions = {}

      _.forEach(rawData, function (item) {
        priceOptions[item.value] = (priceOptions[item.value] + 1) || 1
      })

      var priceOptionsSorted = _.sortKeysBy(priceOptions, value =&gt; -value)

      console.log(priceOptionsSorted);
    })
  })
}
</code></pre>