Created
January 24, 2020 15:40
-
-
Save brianfiszman/8d175f42f5110b0e2217ed2561748d86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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