I'm using node.js to execute a simple JavaScript script that tests access to the rinkeby blockchain using an infura endpoint. specifically, it is checking the balance of my address.
In the code if I invoke:
console.log(web3.eth.getBalance(address));
it only returns the Promise i.e.
Promise {
_bitField: 0,
_fulfillmentHandler0: undefined,
_rejectionHandler0: undefined,
_promise0: undefined,
_receiver0: undefined }
If on the other hand I call:
console.log(web3.eth.getBalance(address, function (error, result) { }));
it returns both the Promise and the address balance i.e..
Promise {
_bitField: 0,
_fulfillmentHandler0: undefined,
_rejectionHandler0: undefined,
_promise0: undefined,
_receiver0: undefined }
18750000000000000000
I don't really understand why it prints out the Promise at all. I simply want it to return the value only i.e. 18750000000000000000
How can I achieve this and do I really need to specify the function (error, result) { }
optional parameter to all the web3 function calls just to get it to return me the data I need?
thanks