Event By contract Right-hand side of 'instanceof' is not an object?

code is here

import Moralis from 'moralis';
import { apikey,marketAddress} from '../../cofig';
import { EvmChain } from '@moralisweb3/common-evm-utils';
export default function Activities() {
  const transfer=async()=>{
    console.log("called")
    try {
      const abi = [{
        "anonymous": false,
        "inputs": [
          {
            "indexed": false,
            "internalType": "uint256",
            "name": "_itemId",
            "type": "uint256"
          },
          {
            "indexed": false,
            "internalType": "address",
            "name": "newOwner",
            "type": "address"
          },
          {
            "indexed": false,
            "internalType": "address",
            "name": "oldOwner",
            "type": "address"
          }
        ],
        "name": "ChangeOwnership",
        "type": "event"
      }];
        const address = marketAddress 
        const topic = "ChangeOwnership(uint256, address, address)"
        const chain = EvmChain.ETHEREUM;

        await Moralis.start({
            apiKey: apikey
        });

        const response = await Moralis.EvmApi.events.getContractEvents({
            address,
            chain,
            abi,
        });

        console.log(response?.result);
    } catch (e) {
        console.error(e);
    }
  }
  useEffect(()=>{
    transfer()
  },[])
    return (
        <div>
          <h1>Hellow </h1>
        </div>
    )
}

but I got an error

TypeError: Right-hand side of 'instanceof' is not an object
    at isApiRequestError (ApiRequestError.ts:12:1)
    at RequestController.makeError (RequestController.ts:71:1)
    at RequestController.<anonymous> (RequestController.ts:56:1)
    at step (ApiRequestError.ts:31:1)
    at Object.throw (ApiRequestError.ts:31:1)
    at rejected (ApiRequestError.ts:31:1)
overrideMethod @ react_devtools_backend.js:4012
transfer @ Activity.js:45
await in transfer (async)
(anonymous) @ Activity.js:49
commitHookEffectListMount @ react-dom.development.js:23150
commitPassiveMountOnFiber @ react-dom.development.js:24926
commitPassiveMountEffects_complete @ react-dom.development.js:24891
commitPassiveMountEffects_begin @ react-dom.development.js:24878
commitPassiveMountEffects @ react-dom.development.js:24866
flushPassiveEffectsImpl @ react-dom.development.js:27039
flushPassiveEffects @ react-dom.development.js:26984
commitRootImpl @ react-dom.development.js:26935
commitRoot @ react-dom.development.js:26682
performSyncWorkOnRoot @ react-dom.development.js:26117
flushSyncCallbacks @ react-dom.development.js:12042
flushSync @ react-dom.development.js:26201
scheduleRefresh @ react-dom.development.js:27795
renderer.scheduleRefresh @ react_devtools_backend.js:6578
(anonymous) @ react-refresh-runtime.development.js:304
performReactRefresh @ react-refresh-runtime.development.js:293
(anonymous) @ RefreshUtils.js:85
setTimeout (async)
enqueueUpdate @ RefreshUtils.js:83
executeRuntime @ RefreshUtils.js:243
$ReactRefreshModuleRuntime$ @ Activity.js:5
./src/components/Ranking/Activity.js @ Activity.js:5
options.factory @ react refresh:6
__webpack_require__ @ bootstrap:24
_requireSelf @ hot module replacement:102
apply @ jsonp chunk loading:444
(anonymous) @ hot module replacement:344
internalApply @ hot module replacement:342
(anonymous) @ hot module replacement:279
waitForBlockingPromises @ hot module replacement:233
(anonymous) @ hot module replacement:277
Promise.then (async)
(anonymous) @ hot module replacement:276
Promise.then (async)
(anonymous) @ hot module replacement:256
Promise.then (async)
hotCheck @ hot module replacement:247
check @ dev-server.js:13
(anonymous) @ dev-server.js:68
emit @ events.js:153
reloadApp @ reloadApp.js:46
warnings @ index.js:261
(anonymous) @ socket.js:60
client.onmessage @ WebSocketClient.js:50

I saw this error before, maybe you can find a solution in other similar forum threads

Im unable to 4 or 5 days ago thing we just fine now its throwing this error and code is total copied from moralis website docs

my original code

import React from 'react'
import Moralis from 'moralis';
import { EvmChain } from '@moralisweb3/evm-utils';
import { apikey, base_Backend_url, eth } from '../../cofig';
import { useState, useEffect } from 'react';
import { marketAddress, polymarketAddress, bnbmarketAddress, bnbtokenAddress, polytokenAddress, tokenAddress, ethauction, polyauction, bnbauction, ethlicensce, polylicensce, bnblicensce } from '../../cofig';
import User from '../plugins/User';
import Dropdown from 'react-bootstrap/Dropdown';
import { Row, Spinner, Button } from "react-bootstrap";
import Users from '../plugins/User';
import './table.css'
import { Link } from 'react-router-dom';
import axios from 'axios';
Moralis.start({
  apiKey: apikey,
  // ...and any other configuration
});
export default function Activities() {
  const [txdata, setTxdata] = useState([])
  const [activity, setActivty] = useState('sale')
  const [ethlength, setethLength] = useState(0)
  const [polylength, setpolyLength] = useState(0)
  const [bnblength, setbnbLength] = useState(0)
  const[loading, setLoading] = useState(true)
  const abi = [{
    "anonymous": false,
    "inputs": [
      {
        "indexed": false,
        "internalType": "uint256",
        "name": "_itemId",
        "type": "uint256"
      },
      {
        "indexed": false,
        "internalType": "address",
        "name": "newOwner",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "address",
        "name": "oldOwner",
        "type": "address"
      }
    ],
    "name": "ChangeOwnership",
    "type": "event"
  }]; // Add ABI
  const abiMint = [{
    "anonymous": false,
    "inputs": [
      {
        "indexed": false,
        "internalType": "uint256",
        "name": "supply",
        "type": "uint256"
      },
      {
        "indexed": false,
        "internalType": "address",
        "name": "_creator",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "uint256",
        "name": "_mintingTime",
        "type": "uint256"
      },
      {
        "indexed": false,
        "internalType": "string",
        "name": "_URI",
        "type": "string"
      },
      {
        "indexed": false,
        "internalType": "uint256",
        "name": "_tokenId",
        "type": "uint256"
      }
    ],
    "name": "CreateCollectible",
    "type": "event"
  }]
  const Auction =[{
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "uint256",
        "name": "id",
        "type": "uint256"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "creator",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "uint256",
        "name": "tokenID",
        "type": "uint256"
      },
      {
        "indexed": false,
        "internalType": "address",
        "name": "NFTaddress",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "uint256",
        "name": "price",
        "type": "uint256"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "owner",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "uint256",
        "name": "itemId",
        "type": "uint256"
      },
      {
        "indexed": false,
        "internalType": "uint256",
        "name": "statingtime",
        "type": "uint256"
      },
      {
        "indexed": false,
        "internalType": "string",
        "name": "uri",
        "type": "string"
      }
    ],
    "name": "AddedAuctions",
    "type": "event"
  }]
  const License = [{
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "uint256",
        "name": "tokenId",
        "type": "uint256"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "seller",
        "type": "address"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "owner",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "uint256",
        "name": "price",
        "type": "uint256"
      },
      {
        "indexed": false,
        "internalType": "bool",
        "name": "sold",
        "type": "bool"
      },
      {
        "components": [
          {
            "internalType": "enum LicensingNFTMarketPlace.LicenseType",
            "name": "licenseType",
            "type": "uint8"
          },
          {
            "internalType": "uint256",
            "name": "registeredOn",
            "type": "uint256"
          },
          {
            "internalType": "uint256",
            "name": "expiresIn",
            "type": "uint256"
          },
          {
            "internalType": "enum LicensingNFTMarketPlace.LicenseState",
            "name": "state",
            "type": "uint8"
          }
        ],
        "indexed": false,
        "internalType": "struct LicensingNFTMarketPlace.LicenseInfo",
        "name": "licenseInfo",
        "type": "tuple"
      }
    ],
    "name": "MarketItemCreated",
    "type": "event"
  }]
  const topic = "ChangeOwnership(uint256, address, address)"
  const minTopic = "CreateCollectible(uint256 ,address ,uint256 ,string ,uint256)"
  const AuctionTopic = `AddedAuctions(uint256,address ,uint256 ,address ,uint256 ,address,uint256 ,uint256 ,string)`
  const LicenseTopic = `MarketItemCreated(uint256,address,address,uint256,bool,LicenseInfo)`
  const ether = EvmChain.GOERLI
  const polygon = EvmChain.MUMBAI
  const Bsc = EvmChain.BSC_TESTNET


  const formatData = (data, symbol, link) => {
    let frmdata = data.map((i) => {
      return { owner: i?.data?.owner, NFTaddress: i?.data?.NFTaddress, price: i?.data?.price, symbol, trx_hash: link + i.transaction_hash, itemId: i.data.itemId, date: i.block_timestamp }
    })
    return frmdata
  }

  const formatData2 = (data, symbol, link) => {
    let frmdata = data.map((i) => {
      return { owner: i?.data?._creator, symbol, trx_hash: link + i.transaction_hash, itemId: i.data._tokenId, date: i.block_timestamp,supply:i.data.supply }
    })
    return frmdata
  }
  const getTransfer = async () => {

    const getNfttxs = async (chain, address) => {
      setLoading(true)
   
      const response = await Moralis.EvmApi.events.getContractEvents({
        address,
        chain,
        abi,topic
    });
      return response?.toJSON().result
    }
    let data1 = await getNfttxs(ether, marketAddress)
    let data2 = await getNfttxs(polygon, polymarketAddress)
    let data3 = await getNfttxs(Bsc, bnbmarketAddress)
    let data = data1.concat(data2, data3)
    setTxdata(data)
    setLoading(false)

  }
  const getTmints = async () => {
    setLoading(true)
    const getNfttxs = async (chain, address, abi, topic) => {
      const response = await Moralis.EvmApi.events.getContractEvents({
        address,
        chain,
        abi, topic
      });
      console.log(response?.toJSON());
      return response?.toJSON().result
    }
    let data1 = await getNfttxs(ether, tokenAddress, abiMint, minTopic)
    let data2 = await getNfttxs(polygon, polytokenAddress, abiMint, minTopic)
    let data3 = await getNfttxs(Bsc, bnbtokenAddress, abiMint, minTopic)
    let frmData1 = await formatData2(data1, 'ETH', 'https://goerli.etherscan.io/tx/')
    let frmData2 = await formatData2(data2, 'MATIC', 'https://mumbai.polygonscan.com/tx/')
    let frmData3 = await formatData2(data3, 'BNB', 'https://testnet.bscscan.com/tx/')
    let data = frmData1.concat(frmData2, frmData3)

    setTxdata(data)
    setLoading(false)
   


  }

  const getAuctions = async () => {
    setLoading(true)
    const getNfttxs = async (chain, address, abi, topic) => {
      const response = await Moralis.EvmApi.events.getContractEvents({
        address,
        chain,
        abi, topic
      });
     
      return response?.toJSON().result
    }
    let data1 = await getNfttxs(ether, ethauction, Auction, AuctionTopic)
    let data2 = await getNfttxs(polygon, polyauction, Auction, AuctionTopic)
    let data3 = await getNfttxs(Bsc, bnbauction, Auction, AuctionTopic)
    let frmData1 = await formatData(data1, 'ETH', 'https://goerli.etherscan.io/tx/')
    let frmData2 = await formatData(data2, 'MATIC', 'https://mumbai.polygonscan.com/tx/')
    let frmData3 = await formatData(data3, 'BNB', 'https://testnet.bscscan.com/tx/')
    let data = frmData1.concat(frmData2, frmData3)

    
    setTxdata(data)
    setLoading(false)

  }

  const getLicense = async () => {
    try {
      setLoading(true)
      let data = await axios.get(base_Backend_url + 'licenses/')
      let tx = data.data
      setTxdata(tx)
      setLoading(false)
     
    } catch (error) {
      console.log(error) 
    }

  }

  useEffect(() => {
    getTransfer()
    


  }, [])

  return (
    <>
      <div className='container'>
        <div className="d-flex justify-content-between">
          <div>
            <h3 className=''>Activity By NFT getty</h3>
          </div>
          <div>
          </div>
          <div>
            <Dropdown>
              <Dropdown.Toggle variant="success" id="dropdown-basic">
                Filter
              </Dropdown.Toggle>

              <Dropdown.Menu>
                {/* <Dropdown.Item href="#/action-1"><img src="https://img.icons8.com/fluency/48/000000/share-3.png"/></Dropdown.Item> */}
                <Dropdown.Item href="#" onClick={(e) => {
                  e.preventDefault()
                  setActivty('auction')
                  getAuctions()
                }}>Auction</Dropdown.Item>
                <Dropdown.Item href="#" onClick={(e) => {
                  e.preventDefault()
                  getLicense()
                  setActivty('license')

                }}>License Creation</Dropdown.Item>
                <Dropdown.Item href="#" onClick={(e) => {
                  e.preventDefault()

                  setActivty('sale')
                }}>Sales</Dropdown.Item>
                <Dropdown.Item href="#" onClick={(e) => {
                  e.preventDefault()
                  setActivty('mint')
                  getTmints()
                }}>Mint</Dropdown.Item>
                {/* <Dropdown.Item href="#" onClick={(e) => {
                  e.preventDefault()
                 
                  setActivty('activation')
                }}>License Activation</Dropdown.Item> */}
              </Dropdown.Menu>
            </Dropdown>
          </div>
        </div>

        <hr className='text-white' />

        {loading ? (

          <Row className="justify-content-center">
            <Spinner animation="border" />
          </Row>
        ) :
          <div className="card tbr" style={{ padding: "0px" }}>
            {activity === 'sale' ?
              // sale
              <table className="table table-borderless shadow-sm bg-body rounded" style={{ padding: "0px " }}>
                <thead className="">
                  <tr>
                    <th scope="col" className='text-white'>#</th>
                    <th scope="col" className='text-white'>From</th>
                    <th scope="col" className='text-white'>To</th>
                    <th scope="col" className='text-white'>contract</th>
                    <th scope="col" className='text-white'>tx Hash</th>
                    <th scope="col" className='text-white'>Price</th>
                  </tr>
                </thead>
                <tbody>
                  {txdata && txdata.map((i, j) => {
                    return (
                      <tr>
                        <th scope="row" className='text-white'>{i?.data?._itemId}</th>
                        <td className='text-cs'><Users user={i?.data?.oldOwner}/></td>
                        <td className='text-cs'><Users user={i?.data?.oldOwner}/></td>
                        <td className='text-cs'>{i?.address?.slice(0, 6)}...</td>
                        <td className='text-cs'>{i?.transaction_hash?.slice(0, 6)}...</td>
                        <td className='text-cs'>0.01 Eth</td>
                      </tr>
                    )
                  })}
                </tbody>
              </table> : activity === 'mint' ?
                //  mint
                <table className="table table-borderless shadow-sm p-3 mb-5 bg-body rounded">
                  <thead className="">
                    <tr>
                      <th scope="col" className='text-white'>#</th>
                      <th scope="col" className='text-white'>Supply</th>
                      <th scope="col" className='text-white'>User</th>
                      <th scope="col" className='text-white'>Mintin Time</th>
                      <th scope="col" className='text-white'>tx Hash</th>
                    </tr>
                  </thead>
                  <tbody>
                    {txdata && txdata.map((i, j) => {
                      return (
                        <tr>
                          <th scope="row" className='text-white'>{i?.itemId}</th>
                          <td className='text-cs'>{i?.supply}</td>
                          <td className='text-cs'><Users user={i?.owner}/></td>
                          <td className='text-cs'>{i?.date?.slice(0, 10)}</td>
                          <td className='text-cs'><a href={i?.trx_hash} target="_blank">{i?.trx_hash?.slice(0, 6)}</a></td>
                        </tr>
                      )
                    })}
                  </tbody>
                </table> : activity === 'license' ?
                  // license
                  <table className="table table-borderless shadow-sm p-3 mb-5 bg-body rounded">
                    <thead className="">
                      <tr>
                        <th scope="col" className='text-white'>#</th>
                        <th scope="col" className='text-white'>user</th>
                        <th scope="col" className='text-white'>contract</th>
                        <th scope="col" className='text-white'>Price</th>
                      </tr>
                    </thead>
                    <tbody>
                      {txdata && txdata.map((i, j) => {
                      

                        return (
                          <tr>
                            <th scope="row" className='text-white'>{i?.itemId}</th>
                            <td className='text-cs'><User user={i?.owner} /></td>
                            <td className='text-cs'>{i?.contract_address?.slice(0, 6)}...</td>
                            <td className='text-cs'>{i?.price?.slice(0, 6)}...</td>

                            {/* <td className='text-cs'>0.01 Eth</td> */}
                          </tr>
                        )


                      })}
                    </tbody>
                  </table> :
                  // auction
                  <table className="table table-borderless shadow-sm bg-body rounded">
                    <thead className="">
                      <tr>
                        <th scope="col" className='text-white'>#</th>
                        <th scope="col" className='text-white'>Date</th>
                        {/* <th scope="col" className='text-white'>Time</th> */}
                        <th scope="col" className='text-white'>User</th>
                        <th scope="col" className='text-white'>Tx Hash</th>
                        {/* <th scope="col" className='text-white'>tx Hash</th> */}
                        {/* <th scope="col" className='text-white'>Chain</th> */}
                        <th scope="col" className='text-white'>Price</th>
                      </tr>
                    </thead>
                    <tbody>
                      {txdata && txdata.map((i, j) => {

                        
                        return (
                          <tr>
                            <th scope="row" className='text-white'>{i.itemId}</th>
                            <td className='text-cs'>{i?.date?.slice(0, 10)}</td>
                            {/* <td className='text-cs'>{i?.block_timestamp?.slice(11, 16)}</td> */}
                            <td className='text-cs'><Link to={`author/${i?.owner?.toLowerCase()}/detail`}><Users user={i?.owner?.toLowerCase()} /></Link></td>
                            <td className='text-cs'><a className='btn btn1' href={i.trx_hash} target="_blank">View</a></td>
                            {/* <td className='text-cs'>{i?.block_hash?.slice(0, 10)}...</td> */}
                            {/* <td className='text-cs'>{'Ethereum'}...</td> */}
                            <td className='text-cs'>{parseInt(i?.price) / 100000000000000000} {i.symbol}</td>
                          </tr>

                        )

                      })}
                    </tbody>
                  </table>
            }
          </div>
        }
      </div>
    </>
  )
}

``

any workaround that you would lik to recomend

I don’t know the solution, I’m not expert in react. I saw this error mentioned on forum before.