'Cannot read properties of null (reading 'toString')

const networksId = await web3.eth.getId()
   const tokenData = Token.networks[networksId]
   if(tokenData){
      const token = new web3.eth.Contract(Token.abi, tokenData.address)
      this.setState=({token})
      let tokenBalance = await token.methods.balanceOf(this.state.account).call()
      console.log("tokenBalance", tokenBalance.toString())
      this.setState({ tokenBalance: tokenBalance.toString() })

I'm trying to get the balance of a wallet and it's showing this error.

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source