this is my code
for(var i = 0 ; i <= 4 ; i++){
myContract.methods.contractmanager(i).call().then((res)=>{
console.log(res[0]);
}):
}
there is 2 data stored in my contract and i want to print it but it is not always 2 and it will be more and dynamic and i wont know how many they will be. after executing this code i have 2 output and 2 error. how to make the loop stop at 2 and it wont show the errors? how to detect the error and break the loop? how to find out if the output is empty or not? solidity code:
function contractmanager(uint i) public view returns(uint , address , address , uint , uint , uint){
return (contrs[list_contr[i]].idc , contrs[list_contr[i]].seller , contrs[list_contr[i]].buyer, contrs[list_contr[i]].price ,contrs[list_contr[i]].date , contrs[list_contr[i]].pos );
}