0

I am trying to copy the following curl command using meteor HTTP

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

The command is from here

This is what I tried:

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

but it returns null. The curl command gives {"jsonrpc":"2.0","id":83,"result":"(the blocknumber)"}

9
  • HTTP.call('POST',"localhost:8545",{data:{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}},function(error,res){console.log(res)}) Commented Jul 3, 2017 at 20:39
  • @iiro Thanks I'm at home atm ill try it tomorrow :) Commented Jul 3, 2017 at 23:06
  • @iiro I got this error: XMLHttpRequest cannot load localhost:8545. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. Commented Jul 4, 2017 at 9:51
  • Did you put http:// before localhost? The SO have made a link of the url and the htt not showing up. Commented Jul 4, 2017 at 10:23
  • If I add http:// to the command you gave it becomes identical to the one in my post doesn't it? Commented Jul 4, 2017 at 10:30

1 Answer 1

1

You have to swap error and res params.

HTTP.call('POST',"http://localhost:8545",{data:{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}},function(error, res){console.log(res)})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.