Get NFTs owned solution / React

You can get the NFTs for any address, but if you want for a user then you’ll have to know the user address, so it makes sense for the user to be logged in this case.

ok I am a little confused with all these API changes.
Then what method should I use to get the NFTs for a specified (user) address?

You have the address as an optional parameter, if you don’t set it then the SDK will use current user address. And depending on your needs you can use Moralis.Web3API.account.getNFTsForContract or Moralis.Web3API.account.getNFTs

Thanks! you helped a lot. I got it working :beer:

1 Like

i get an error when i try to use this. what am i doing wrong?

Hey @baalzimon,

I tried hitting it from my end with the same options and it worked. Could you try again and let us know.

Thanks.

If you still get that error, you can paste what console.log(options) shows as parameters.
Does any other Moralis.Web3API function work for you properly?
You can also paste your application id and server url so what we can test with your server too.

other Moralis.Web3API do not seem to work. but Moralis.Web3 does seem to work

I get this error if I say concole.log(options)

This error looks like the case when you are not logged in, you can pass “address” parameter directly if you want.

still doesn’t work.

upper one gives error, lower one works fine.

Please share the error message and server subdomain :raised_hands:

Error below. what is a server subdomain?

Lower one uses outdated syntax, you need to migrate to Moralis.Web3API from Moralis.Web3

the lower one works though.

the web3api line does not.

I copied both directly from the moralis documentation.

that address parameter that you send there in address: address, are you sure it is set?

yes, works perfectly in the lower function.

the only thing that doesn’t work is the Web3API section.

I don’t know how you call those functions. I don’t know what is in that address variable.
Can you paste server app id and server url?

What you get if you run console.log(Moralis.CoreManager.get("VERSION"))

ok, this means that you are using latest Moralis SDK version

none of the web3API functions work.