[object Object]

When running below function; i keep getting a [object Object] response.


 const balance = await Moralis.Web3API.account.getNativeBalance()
        document.getElementById('balance').innerHTML = balance;

are you authenticated, are you using latest version of Moralis Server?

yes to both questions

here is the complete code
I can get the user.address, but for all other calls i get [object Object]

/** Connect to Moralis server */
const serverUrl = ā€œā€;
const appId = ā€œā€;
Moralis.start({ serverUrl, appId });

/** Add from here down */
async function login() {
let user = Moralis.User.current();
if (!user) {
try {
user = await Moralis.authenticate({ signingMessage: ā€œHello to SnoopDoggNFTā€ })
const userAddress = user.get(ā€˜ethAddressā€™)
document.getElementById(ā€œuserā€).innerHTML = userAddress;

    // get BSC native balance for a given address
    
    const balance = await Moralis.Web3API.account.getNativeBalance()
    document.getElementById('balance').innerHTML = balance;

    const tokenBalance = await Moralis.Web3API.account.getTokenBalances();
    document.getElementById('tokenBalance').innerHTML = tokenBalance;   

    const userTrans = await Moralis.Web3API.account.getTokenTransfers();
    document.getElementById('userTrans').innerHTML = userTrans;

} catch(error) {
console.log(error)
}
}
}

what is the server subdomain/url?

server url moralis url

I donā€™t see errors in the server logs

I can do

const balance = await Moralis.Web3API.account.getNativeBalance()
document.getElementById(ā€˜balanceā€™).innerHTML = balance[ā€˜balanceā€™];

which gives back an integer, however, the nativeBalance is not right
It says 0, but I have 0.08345 BNB balance

did you try console.log(balance) to see what it is there?

yes, in console.log I get this

Object { balance: "0" }

Array []

Object { total: 0, page: 0, page_size: 500, result: [] }

as I said the balance is not accurate

and if you set chain and address for that Moralis.Web3API.account.getNativeBalance(), you still donā€™t get accurate data?

yes this seems to work