Skip to content

Multiple API requests #4505

Answered by markerikson
danthedeckie asked this question in Q&A
Jul 10, 2024 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Seems like that would work better with standard async logic:

async function onClick() {
  const [resultA, resultB] = await Promise.all([
    createThingA(props.thingADetails).unwrap(),
    createThingB(props.thingBDetails).unwrap()
  ])
  
  // both must have succeeded
  const resultC = await createThingC(resultA.data.id, resultB.data.id).unwrap();
  navigate(`/url/${resultC.data.id/`);
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@danthedeckie
Comment options

@markerikson
Comment options

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