As I said in my other question, I'm using web3.js to create a DAPP. The problem is that it takes a lot to receive the update after the "await" function. In the following code:
allowAddress = async() => {
let approvedAddress = this.state.approvedAddress;
let approvedValue = this.state.amountAllowed;
this.setState({infoMessage:'Waiting for transaction...'});
try{
let accounts = await web3.eth.getAccounts();
await ContractName.methods.approve(approvedAddress, approvedValue).send({
from: accounts[0]
// value: web3.utils.toWei('0', 'ether')
});
console.log("IT WORKED");
}
catch(err){
this.setState({infoMessage:"something went wrong"});
}
}
console.log("IT WORKED");
works only and only after a very long time. Now I can't even specify the value: web3.utils.toWei('0','ether');
because it stops working.
In the past the part after await would run at the same time as metamask. Is there anything I can do?