This code works correctly. And I just need to export data variable after all promises successfully resolved.
I cannot put this code to function and export variable. Because in this case, this function will export an empty array.
'use strict'
import urls from './urls'
import getData from './get-data'
getData(urls).then((responses) => {
const data = []
const results = responses.map(JSON.parse)
for (let i = 0, max = results.length; i < max; i++) {
// some magic and pushing
}
return data
}).catch(error => console.log(error))