0

If I try to run the example given here: https://web3js.readthedocs.io/en/1.0/web3-eth.html#batchrequest

With the following code:

const batch = new web3.BatchRequest();
batch.add(web3.eth.getBalance.request('0x0000000000000000000000000000000000000000', 'latest'));

batch.execute()
.then(res => console.log(res))
.catch(err => console.log(err));

I get the error:

TypeError: method.callback is not a function

Does anybody have experience with this?

version: "web3": "^1.0.0-beta.55"

  • at what line are you getting this? – Sanjay S B Jul 2 '19 at 5:19
  • Try 1.0.0-beta.34 instead. – goodvibration Jul 2 '19 at 5:21
  • @SanjaySB at node_modules/web3-providers/dist/web3-providers.cjs.js:823:22 at Array.forEach (<anonymous>) at node_modules/web3-providers/dist/web3-providers.cjs.js:808:23 at process.internalTickCallback (internal/process/next_tick.js:77:7) – jasper Jul 2 '19 at 8:58
2

For some reason (this is not documented anywhere I could find) the request method requires a callback function as a last parameter, as such:

const batch = new web3.BatchRequest();
batch.add(web3.eth.getBalance.request('0x0000000000000000000000000000000000000000', 'latest', (err, res) => console.log(err, res));

batch.execute()
.then(res => console.log(res))
.catch(err => console.log(err));
| improve this answer | |
  • thanks, still not documented properly! – Spyros Sep 19 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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