var test = await web3.eth.getBlockNumber();

I copied this code from the docs but when I call it I get this error:

TypeError: e is not a function

Anyone know what might be causing this?

I'm able to do

userAccountAddress = await web3.eth.accounts[0];

no problem.

Thanks

Most web3.js objects allow a callback as the last parameter, as well as returning promises to chain functions.

The error TypeError: e is not a function means it is missing callback function.

In your case await must work out of box, I'm thinking you're use it wrong, here is an example from documentation getBlockNumber():

web3.eth.getBlockNumber().then(console.log);
> 2744

If you still want use await you must use it right, with async keyword.

(async ()=> { await web3.eth.getBlockNumber(console.log) })()
> 2744

Looks ugly ya? That's javascript my friend.

Tip: If you want the blocknumber you can use web3.eth.blockNumber.

  • 1
    Please make the tip larger, it works great in truffle develop! – PaulRBerg Aug 19 at 0:42

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.