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

I am having trouble fetching testnet nfts…

import React from “react”;
import { useMoralisWeb3Api, useMoralis } from “react-moralis”;

const Web3Api = useMoralisWeb3Api();
const { chainId, account, isWeb3Enabled } = useMoralis()

`const fetchNFTs = async () => {

// get testnet NFTs for user
const testnetNFTs = await Web3Api.Web3API.account.getNFTs({
chain: “goerli”,

when I console.log(account) I get the logged in account in my console so I am unsure as to what the issue is.

did you try to use useEffect? where did you use console.log(account)?

Yes I used useEffect to call fetchNFTs… my console.log is straight after the fetchnfts async function - not in the useeffect… I still shows up in the console though

did you try to set the address parameter?

yes sir I did indeed

even changed account to addy as I thought maybe that was the issue

const {Web3Api} = useMoralisWeb3Api;
const { chainId, account, isWeb3Enabled } = useMoralis()

const addy = account
    const fetchNFTs = async () => {
    const testnetNFTs = await Web3Api.account.getNFTs({
        chain: "rinkeby",
        address: {addy},

both addy and account console.log successfully

also - moralis docs have the line Web3Api.Web3API.account.getNFTs - it looked wrong to me but I’m not the most learnered so I tried it anyway unsuccessfully

and it works like that or it doesn’t work?

Does not work - same error

try with hardcoded values to see if it works

Tried and it’s still giving me the same error… the docs say Web3Api.Web3API.account.getNFTs instead of Web3Api.account.getNFTs is this an error?

here it may be the wrong syntax, maybe it is useMoralisWeb3Api()

Was my mistake in typing - the error remains… Kindly inform me on whether its meant to be Web3Api.Web3API.account.getNFTs

it shouldn’t be Web3Api twice, where did you see that in docs?

Looks like a typo, you can try with it only once

Thanks… I’m still getting the error however

What version of packages are you using?

Not really sure - what packages should I check?

I’d assume the latest but I’d need to run a check

Try this: