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

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

Error: required param address not provided

required param address not provided

const {isInitialized, Moralis} = useMoralis()
  

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

You have to also provide address parameter, if the user is not authenticated

thanks that seemed to do the trick!!

1 Like