4

I get the error TypeError: XMLHttpRequest is not a function when I try to connect to a node on the server side of my meteor application.

The error is caused by meteor using the meteor HTTP package instead of XMLHttpRequest. From this question.

How else can a meteor app connect to an ethereum node from the server side?

  • Did you find a solution for this problem? I have the same issue. – Bumblebee Jun 27 '17 at 17:32
  • @Bumblebee no im still trying – Joe Jun 28 '17 at 8:52
  • Meteor uses a different http module docs.meteor.com/api/http.html and here is an issue on we3js #579 – niksmac Jul 3 '17 at 12:35
  • @niksmac could you explain a bit further- what do I need to do to get it working? – Joe Jul 3 '17 at 12:38
  • Simply put, its not a web3 related issue. If you can use the web3 js outside the scope of Meteor; it might work, idk. Never used Meteor. – niksmac Jul 3 '17 at 12:43
0

I had the same problem and finally found the solution. I followed this guide and it worked.

https://github.com/ethereum/wiki/wiki/JavaScript-API#usage

Web3 has to be decleared like this:

var Web3 = require('web3');

and then you can create an instance of Web3 like this:

if (typeof web3 !== 'undefined') {
    web3 = new Web3(web3.currentProvider);
} else {
    web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));        
};

I hope this helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.