[SOLVED] getNfts (Cannot read properties of undefined (reading 'account'))

what is the code that you use now?

you can also look here on how to post code on forum:

  const {Web3Api} = useMoralisWeb3Api();
  const {isInitialized} = useMoralis()

  const fetchNFTsForContract = async () => {
    const options = {
      chain: "rinkeby",
      token_address: "0xf4DEd30B6ca5a6A40f56D9Fe066A9951571C6E3C",
    };
    
  const wrldhorse = await Web3Api.account.getNFTsForContract(options);
  console.log(wrldhorse);
  }
  useEffect(() => {
    if (isInitialized) {
        fetchNFTsForContract()
    }
}, [isInitialized])

what do you get if you use console.log(Moralis.CoreManager.get("VERSION")) ?
after you import Moralis from useMoralis probably

const Web3Api = useMoralisWeb3Api();

const fetchNFTs = async () => {

  // get testnet NFTs for user
  const testnetNFTs = await Web3Api.account.getNFTs({
    chain: "rinkeby",
    address:"0x1e699dd390607a8dc54cdbd64d1a97775901a06f",
  });
  console.log(testnetNFTs);

js1.11.0 - this is what I get

for me it looks like you are using the right syntax:

js1.11.0 this is what I get

what exactly does the account represent in this context? I understand it is somehow getting the logged in account but I assume its not in address format or it would easily be replaceable… My question is directed at trying to troubleshoot where I’ve gone wrong (be it a package or somewhere else)

try to check if that account from Web3Api is defined or not

this still doesn’t work?

Still getting undefined

Its not getting account from web3api

Maybe it has to be imported differently? For web3api I mean

Not too sure there is a different way to import it

You can also use it directly with Moralis.

I don’t understand - kindly elaborate

I have even tried by setting moralis auth to true and no cigar

The same syntax as in vanilla js

Something like Moralis.web3api.account. This is not the exact syntax

const testnetNFTs = await Moralis.Web3API.account.getNFTs({ chain: "goerli" });

? what imports would be required in this instance?

Same import that you used for getting the version before