What is the best way to handled nested contract call with web3 1.0? I'm trying to collect all data needed and format it into something useable. It could require 2 or 3 calls though. Is there a easy way to handle it, to know when all async calls have finished?
this.contract.methods.getPlayerAnimals(this.address)
.call({ from: this.address })
.then((animals) => {
for (var animal of animals) {
this.contract.methods.getAnimal(animal)
.call({ from: this.address })
.then((animalContract) => {
this.playerAnimals.push(fullAnimal)
});
}
this.socket.emit('playerAnimals', this.playerAnimals)
});