near-api-js getAccountBalance()?

659 Views Asked by At

Hello im try get account balance after signin always send the same error

if (window.walletConnection.getAccountId()) {
  window.account = await near.account(walletConnection.getAccountId());
  window.account.getAccountBalance().then(balance=>{
    console.log(balance)
  }).catch(e =>{
    console.log(e)
  })
}

*TypeError: Cannot read properties of undefined (reading 'storage_amount_per_byte') at Account.getAccountBalance (near-api-js.js:346:78)

UPDATE config:

    const config = {
    nodeUrl: "https://rpc.testnet.near.org",
    deps: {
        keyStore: new nearApi.keyStores.BrowserLocalStorageKeyStore(),
    },
    networkId: 'testnet',
        nodeUrl: 'https://rpc.testnet.near.org',
    contractName: CONTRACT_NAME,
    walletUrl: 'https://wallet.testnet.near.org',
    helperUrl: 'https://helper.testnet.near.org'


};
0

There are 0 best solutions below