getNFT function under Accounts API (Web3 API)

the documents ( specify that it is optional to specify the address when making a request, but when I leave the request blank, i get an error saying that Property ‘address’ is missing in type ‘{ chain: “rinkeby”; }’ but required in type ‘{ address: string; }’.

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

this is the line of code causing the issue.

My goal is to build a web application where users can view their NFTs dynamically thus I do not want to hardcode the address.

I’m new to development, so any form of help would be appreciated!

I think that you didn’t mention if you are using typescript

you can get dynamically the address of current user and put it as a parameter for that function, you don’t have to hardcode it

yup, I am using typescript! would this issue not arise in javascript?

and is this the right way to get the address of the user dynamically -

thanks again!

Hi @rahulsw

This one is on typescript only.
If you want to get an address of the active session user - yes, if you want to get the address of the active wallet in metamask right now - no. In the second case it’s better to get it from the Web3 example:

const account = (await web3.eth.getAccounts())[0];