Answer the question
In order to leave comments, you need to log in
How to perform routing after several requests have returned success?
I send several requests on click, how to correctly and beautifully track the success of these requests and then perform some action, for example, routing
Answer the question
In order to leave comments, you need to log in
const Component = () => {
const history = useHistory();
const handler = async () => {
await firstRequest();
await secontRequest();
await thirdRequest();
history.push("/myroute");
}
return (...);
}
const Component = () => {
const history = useHistory();
const handler = async () => {
await Promise.all([
firstRequest(),
secontRequest(),
thirdRequest(),
]);
history.push("/myroute");
}
return (...);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question