I followed a tutorial about how to connect web3 with ethereum networks. I registered in infura.io and get all the urls. But when I try to connect to any network it is not connecting.When I print web3 connection status is always false. Below is my code and I use 1.0.0-beta.34 of web3
web3 = new Web3(new Web3.providers.HttpProvider('https://rinkeby.infura.io/v3/MY_API_KEY'));
web3.eth.net.getNetworkType(function(err, res){
console.log("Network Type: "+res); //Displaying undefined
});
I tried with main net, ropsten and kovan. All are displaying undefined
. I don't know what is the problem here. All example in web are showing these lines only. Can some one help me to solve this? Thank you.
v3
is a new end-point? my infura url doesn't havev3
like yours