TypeError: XMLHttpRequest is not a function when using web3 on meteor server side

0 votes

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.

Oct 10, 2018 in Blockchain by digger
• 26,550 points
77 views

1 answer to this question.

0 votes

I had the same problem. Instead ethereum:web3 Meteor package I have used web3@0.20.1 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 web3@0.20.1 --save

and replace

import { Web3 } from 'meteor/ethereum:web3';

with

import Web3 from 'web3';
answered Oct 10, 2018 by Omkar
• 67,480 points

Related Questions In Blockchain

0 votes
1 answer

Error using EtherJS: this.provider.getTransactionCount is not a function

With this line it should work fine: wallet.provider ...READ MORE

answered Sep 26, 2018 in Blockchain by digger
• 26,550 points
123 views
0 votes
1 answer

How can we decrypt a transaction payload when confidentiality is on?

You can try the following: you can only ...READ MORE

answered May 2, 2018 in Blockchain by Shashank
• 10,350 points
71 views
0 votes
1 answer
0 votes
1 answer

Truffle dev says my function is not a function

It seems you are using truffle v5. ...READ MORE

answered Jan 24 in Blockchain by Omkar
• 67,480 points
39 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
141 views
0 votes
1 answer
+3 votes
2 answers

How to run ethereumjs using Node.JS

You need to install testrpc globally on ...READ MORE

answered Mar 27, 2018 in Blockchain by ned_crew
• 1,620 points
136 views
0 votes
1 answer
0 votes
1 answer

Ethereum "truffle server" gives error: TypeError: fsevents is not a constructor

Looks like you have files missing.  Try creating project with: truffle ...READ MORE

answered Nov 30, 2018 in Blockchain by Omkar
• 67,480 points
144 views