How can I export promise result? : <p>Sorry if this question is stupid.</p>

<p>This code works correctly. And I just need to export data variable after all promises successfully resolved.</p>

<p>I cannot put this code to function and export variable. Because in this case, this function will export an empty array.</p>

<pre class="lang-js prettyprint-override"><code>'use strict'

import urls from './urls'
import getData from './get-data'

getData(urls).then((responses) =&gt; {
    const data = []
    const results = responses.map(JSON.parse)

    for (let i = 0, max = results.length; i &lt; max; i++) {
        // some magic and pushing 
    }

    return data
}).catch(error =&gt; console.log(error))
</code></pre>
