dappuniversity / token_sale

Code Your Own Cryptocurrency & ICO on Ethereum | Tutorial
406 stars 387 forks source link

GetAccounts (Capstone Project Pt. 2-UI Setup) #28

Open RaynHarr opened 4 years ago

RaynHarr commented 4 years ago

Hi Hoping to get some eyes on this. Trying to get through the Capstone project and for some reason my array of accounts is coming up blank [] in the console:

import React, { Component } from 'react';
import './App.css';
import Web3 from 'web3'

class App extends Component {
    componentWillMount() {
      this.loadBlockchainData()
    }

    async loadBlockchainData() {
      const web3 = new Web3(Web3.givenProvider || 'http://localhost:7545')
      const network = await web3.eth.net.getNetworkType()
      const accounts = await web3.eth.getAccounts()
      console.log('accounts', accounts)
    }