Errors token price function

Hi, everyone. I was trying to create a function that shows every second the current price of one token, which address is given by a parameter. The function works and shows the price in the console, but I have constantly this two errors:

- moralis.js:29036 POST https://b6hr8gxghw0m.usemoralis.com:2053/server/functions/getTokenPrice 400

- script.js:391 Uncaught (in promise) {code: 141, error: 'required param address not provided'}

What do these errors mean? What could I do to fix them?

HERE IS THE CODE:


 async function getPrice(tA) {
    var options = { address: "", chain: "bsc" }
    options.address = tA
    setInterval(async function gtp(options) {
        const price = await Moralis.Web3API.token.getTokenPrice(options);
        console.log((price.usdPrice).toFixed(18));
    }, 1000)
}

you could add some logging to see what you have in options there, maybe you donโ€™t have an address there

This is an example of the code that I use to call the function for a specific token in the balance of the user. Shouldnโ€™t it provide to the function the address of the token being considered?

const options = { chain: 'bsc' }
var balance = await Moralis.Web3.getAllERC20(options);

getPrice(balance[1].tokenAddress)

you should use getTokenBalances: https://docs.moralis.io/moralis-server/web3-sdk/account#gettokenbalances

and you have to filter from the output what token are you interested in