I have a function in React app where will be made three different http calls:
const handleEditUser = async () => {
let p1, p2, p3;
p1 = UserUtils.setProjects(user, client, newProjects);
p2 = UserUtils.updateRights(user.id, userAuthority);
p3 = UserUtils.updateUserClient(client, user);
await Promise.all([p1, p2, p3]);
}
My problem is that p2
request will be executed before p1
request was completely finished.
I would like to build some timeouts or something else which allows to execute p2
after p1
is finished and p3
after p2
is finished.
I tried to replace Promise.all[]
with the lines below, but it didn't solve my problem:
await p1;
await p2;
await p3;