Reputation: 321
I get the error TypeError: XMLHttpRequest is not a function
when I try to interact with a contract on the server side of my meteor application.
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"))
var cocontract = web3.eth.contract(abi).at(address);
var name = (cocontract.name())
The error is raised with the 3rd line. If I run the same code on the client side I don't get a problem.
Upvotes: 1
Views: 749
Reputation: 21
I had the same problem. Instead ethereum:web3
Meteor package I have used [email protected]
NPM package, and it works ok (Meteor version 1.5.1).
So, if you using ethereum:web3
you probably need to run:
meteor remove ethereum:web3
meteor npm install [email protected] --save
and replace
import { Web3 } from 'meteor/ethereum:web3';
with
import Web3 from 'web3';
Upvotes: 2
Reputation: 1579
I haven't used web3, but I suspect it's taking advantage of the XMLHttpRequest
, which is only present in browsers. Try getting an analogue for that on the server. I'd start with this one:
xmlhttprequest
Upvotes: 0