Skip to content

Multiple requests #786

Answered by kg55kmr
kg55kmr asked this question in Q&A
Nov 23, 2020 · 3 comments · 12 replies
Discussion options

You must be logged in to vote

Done it.

function fetcher(...urls) {
  const f = (u) => fetch(u).then((r) => r.json());

  if (urls.length > 1) {
    return Promise.all(urls.map(f));
  }
  return f(urls);
}

Replies: 3 comments 12 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
9 replies
@OutThisLife
Comment options

@Angeloem
Comment options

@evanxd
Comment options

@Angeloem
Comment options

@shuding
Comment options

Answer selected by shuding
Comment options

You must be logged in to vote
3 replies
@daun-io
Comment options

@0xbe1
Comment options

@0xbe1
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
10 participants