使用meteor HTTP连接到以太坊节点

时间:2017-07-03 15:08:09

标签: meteor http-post

我正在尝试使用meteor HTTP

复制以下curl命令

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}' http://localhost:8545

该命令来自here

这就是我的尝试:

HTTP.call('POST',"http://localhost:8545",{data:{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}},function(res,error){console.log(res)})

但它返回null。 curl命令提供{"jsonrpc":"2.0","id":83,"result":"(the blocknumber)"}

1 个答案:

答案 0 :(得分:1)

你必须交换错误和res params。

HTTP.call('POST',"http://localhost:8545",{data:{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}},function(error, res){console.log(res)})