Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on The Way of the Gopher: Making the Switch from Node.js to Golang. Parent comment
return arr.map(ele => await axis.get(ele));
return arr.map(async ele => await axis.get(ele));
return arr.map(ele => axis.get(ele));
That is, it returns an array of promises of values, not a promise of an array of values like erlich's function.
erlich's example is correct, with the replacement of for-in with for-of.
Edit:
Also, a solution using Array.map() is not impossible:
return Promise.all(arr.map(ele => axis.get(ele)));
There are no comments on this comment yet.
That is, it returns an array of promises of values, not a promise of an array of values like erlich's function.
erlich's example is correct, with the replacement of for-in with for-of.
Edit:
Also, a solution using Array.map() is not impossible:
but this has different characteristics than the original function. The original ran the tasks in series whereas this runs them in parallel.