Skip to content

Instantly share code, notes, and snippets.

@brianfiszman
Created January 24, 2020 15:40
Show Gist options
  • Save brianfiszman/8d175f42f5110b0e2217ed2561748d86 to your computer and use it in GitHub Desktop.
Save brianfiszman/8d175f42f5110b0e2217ed2561748d86 to your computer and use it in GitHub Desktop.
const {get} = require("axios");
const urls = [get("https://www.google.com"), get("https://www.yahoo.com"), get("https://www.facebook.com")];
async function processTasks() {
return urls.reduce(async (accPromise, u, i) => {
const acc = await accPromise;
const {data, ...r} = await u;
acc[i] = r.config.url;
return acc;
}, Promise.resolve({}));
}
processTasks()
.then(console.log)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment