I have a function that takes an array of URLs and downloads them. It looks like this:
const loadFiles = filePaths => {
  return new Promise((resolve, reject) => {
    let fetchPromises = filePaths.map(filePath => fetch(filePath))
    Promise.all(fetchPromises).then(fetchResolves => {
      let textPromises = []
      fetchResolves.forEach(fetchResolve => {
        if (!fetchResolve.ok) {
          return reject(`${fetchResolve.statusText} : ${unescape(fetchResolve.url)}`)
        }
        textPromises.push(fetchResolve.text())
      })
      Promise.all(textPromises).then(resolve)
    })
  })
}
export {loadFiles}
The issue I am having is that the multiple calls to Promise.all start to resemble callbacks even though I am using promises.
Is there a way to map the functionality of Promise.all to async and await to simplify this function?
How do I do this?
 
    