Comment

Comment by Etheryte

While the idea is correct, the proposed solution is needlessly verbose. A better solution would be to

  async function getPeople() {
    const [members, nonMembers] = await Promise.all([
      fetch("/members"),
      fetch("/non-members"),
    ]);
    return members.concat(nonMembers);
  }
The gist of the article is very true though. This is something that comes up every now and then in code review, even with seasoned developers. I'm not entirely sure what the solution would be since depending on the context, both sequential and parallel execution can be correct. It might just be one of those rite of passage type of mistakes you have to make once or twice.
parent Etheryte 6 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton