I'm exploring web3 following instructions from the docs and running the code below. The function throws with the error message being: Error: Invalid JSON RPC response: ""
For context the code below works when running a local node script, but gives me the error when running in a Node 8 environment hosted by firebase.
What am I doing wrong and can anyone explain what it means?
const web3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io/v3/<project ID>"))
const weiBalance = await web3.eth.getBalance("0x52bc44d5378309EE2abF1539BF71dE1b7d7bE3b5")
console.log(weiBalance)
web3.eth.getBalance
returns a Promise object, which you need to resolve in order to get the actual balance of the input address. – goodvibration Dec 29 '20 at 17:34