I've just been trying to run the web3.eth.getBlock
request as a test.
If I set my web3 provider to https://api.myetherapi.com/eth
then the call is successful and returns the information about the block. However myetherapi has request limits so I figured I'd install geth and run my own node for this.
I installed geth and let it synch. Changed my web3 provider tocalhost http://localhost:8545 and I just get the following:
Unhandled rejection Error: Invalid JSON RPC response: "".
myetherapi set provider:
web3.setProvider(new web3.providers.HttpProvider('https://api.myetherapi.com/eth'));
local provider:
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));
Am I missing something key here? Thank you for the help.
var Web3 = require('web3');
var web3 = new Web3();
//not working provider. returns the above error
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));
//this provider works but it is myetherapi with api limits.
//web3.setProvider(new web3.providers.HttpProvider('https://api.myetherapi.com/eth'));
web3.eth.getBlock(5099447);
geth
with the right command-line parameters. Trygeth --rpc --rpcapi="eth,web3,personal"
.