简体   繁体   中英

web3 getAccounts doesn't get resolved

web3.eth.getAccounts() is not working for me. The code below shows "error" on execution (gets rejected). I am using web3 1.0.0 beta-46. I am learning from Stephen Grider's tutorial videos and he used beta-26, is it version related issue or am i doing something wrong?

const assert = require('assert');
const ganache = require('ganache-cli');
const Web3 = require('web3');
const web3 = new Web3(ganache.provider());

web3.eth.getAccounts()
    .then(fetchedAccounts => {
      console.log(fetchedAccounts);
    },() => {
      console.log("error");
    });

Haven't tried it myself but this seems to be a bug with the latest versions of web3 . Try with 1.0.0 beta-37 ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM