Code sample

Quickly mapping an array of URLs to responses with JavaScript async/await and Promise.all

While perhaps not the most readable, a compact version (using window.fetch) can look like this:

const urls = [
async function fetchAll() {
const results = await Promise.all( => fetch(url).then((r) => r.json())));
console.log(JSON.stringify(results, null, 2));
Joel Abrahamsson

Joel Abrahamsson

I'm a passionate web developer and systems architect living in Stockholm, Sweden. I work as CTO for a large media site and enjoy developing with all technologies, especially .NET, Node.js, and ElasticSearch. Read more

More about Programming