> For the complete documentation index, see [llms.txt](https://strctr.gitbook.io/programming/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://strctr.gitbook.io/programming/01-languages/javascript/01-language/e-controls/e5-async/07-async-functions-callbacks.md).

# 07. Async Callbacks

One limitation of `async` functions is that `await` only affects the directly surrounding async function.

Will return array of Promises:

```javascript
async function downloadContent(urls) {
  return urls.map(async url => {
    const content = await httpGet(url);
    return content;
  });
}
```

There are two issues with this code:

* The result is now an `Array` of Promises, not an `Array` of strings.
* The work performed by the callbacks isn’t finished once `map()` is finished, because `await` only pauses the surrounding arrow function and `httpGet()` is resolved asynchronously. That means you can’t use `await` to wait until `downloadContent()` is finished.

We can fix both issues via `Promise.all()`. We also may remove all unnecessary `await`:

```javascript
async function downloadContent(urls) {
  const promiseArray = urls.map(url => httpGet(url));
  return await Promise.all(promiseArray);
}
```
