5

Which way is recommended to perform multiple mutations in sequence using RTK Query?

  const [
    updateProfile, 
  ] = useUpdateProfileMutation();

  const [
    updatePost,
  ] = useUpdatePostMutation();


  const performMutipleMuations = async () => {
    const data= await updateProfile(newData);
    await updatePost(data);
  };



dan_boy
  • 1,735
  • 4
  • 19
  • 50

1 Answers1

4

Ultimately using unwrap made the trick.

  const performMutipleMuations = async () => {
    const data= await updateProfile(newData).unwrap();
    await updatePost(data).unwrap();
  }
dan_boy
  • 1,735
  • 4
  • 19
  • 50