for (var i = 0 ; i <= 4 ; i++) {
myContract.methods.contractmanager(i).call().then((res) => {
console.log(res[0]);
}):
}
There are 2 data stored in my contract. I want to print it but it is not always 2, sometimes there will be more. It is dynamic and I wont know how many there will be.
After executing this code I have 2 output and 2 error. How do I make the loop stop at 2 so it wont show the errors? How do I detect the error and break the loop? How do I find out if the output is empty or not?
for await of
inside atry {} catch {}
.