Listen to new transaction

i copy the code and paste it on my testing page. it just doesn’t work to get live update of new transaction. any help will be appreciated. following is copied code: -

 async function listenNewTrans() {
        const query = new Moralis.Query('BscTokenTransfers');
        const currentUser = Moralis.User.current();
        // create query
        //const query = new Moralis.Query("EthTransactions");
        query.equalTo("from_address", currentUser.attributes.ethAddress.toLowerCase());

        // subscribe to query updates ** add this**
        const subscription = await query.subscribe();
    async function handleNewTransaction(subscription) {
      // log each new transaction
      subscription.on("create", function(data) {
        console.log("new transaction: ", data);

i get this on my chrome console: -


This is what i have in moralis dashboard

Whenever i make a transfer, this “BscTokenTransfers” object has a new row added but it is not push to chrome.

Try on update instead of on create

yes… it works…
But funny thing is it updates 3 times for one transfer transaction. do you have any idea for that?


I don’t know yet why it updates 3 times