multiple-API-calls-before-executing-next-function-in-React-Promise-2.md

February 15, 2023 ยท View on GitHub

Lets say I have this

this.getList();
this.getServers();
this.getCredentials();
console.log("waited");

What would be a way to console.log only after the other 3 finished? and those 3 are actually API calls.

Solution -

Promise.all([this.getList(), this.getServers(), this.getCredentials()]).then(
  () => console.log("waited")
);