Skip to content

Instantly share code, notes, and snippets.

View ihpannu's full-sized avatar
🏠
Working from home

Harman Pannu ihpannu

🏠
Working from home
View GitHub Profile
@ihpannu
ihpannu / asyncloops.js
Last active June 15, 2019 03:55 — forked from lukehoban/asyncloops.js
Async/await and parallel loops
// ES6 w/ Promises
// Note: From a React starter template - see https://t.co/wkStq8y3I5
function fetchData(routes, params) {
let data = {};
return Promise.all(routes
.filter(route => route.handler.fetchData)
.map(route => {
return route.handler.fetchData(params).then(resp => {
data[route.name] = resp;