Fetch NFT OpenSea empty array [SOLVED]

Hey guys,

When I fetch my NFTs always returns an empty array,

I have NFT’s Rarible and OpenSea,


  const getNonFungibleTokens = async () => {
    if (isAuthenticated) {
      const userEthNFTs = await Moralis.Web3.getNFTs();
      const options = { chain: "matic" };
      const polygonNFTs = await Moralis.Web3.getNFTs(options);
      return polygonNFTs;

Thank you,

Renan Lopes

1 Like

That code looks ok to me. There might be an error in another part of your code. Try using this boilerplate test code, replace your Moralis App Id and server url, then type the getNFTs() query into the console (or add a function call to the snippet). I use a snippet like this for testing a lot. Hard code all the values.

    <!-- Moralis SDK code -->
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/web3.min.js"></script>
    <script src="https://unpkg.com/moralis/dist/moralis.js"></script>
    <h1>Moralis Test</h1>

    <button id="btn-login">Moralis Login</button>
    <button id="btn-logout">Logout</button>

      // connect to Moralis server
      Moralis.initialize("YOUR MORALIS APP ID");
      Moralis.serverURL = "YOUR MORALIS SERVER URL";

      async function login() {
        let user = Moralis.User.current();
        if (!user) {
          user = await Moralis.Web3.authenticate();
        console.log("logged in user:", user);

      async function logOut() {
        await Moralis.User.logOut();
        console.log("logged out");

      // bind button click handlers
      document.getElementById("btn-login").onclick = login;
      document.getElementById("btn-logout").onclick = logOut;

The issue is on the function itself is returning 400 when Eth chain is called,

There are two issues, one is that the default wallet address for the logged user is not being set, the second issue is that when calling Eth chain have some conversion error on this function,

1 Like

Thanks for reporting these bugs! Fixes for both the parse error and user address error will be in an upcoming Moralis Server version.

1 Like

This should be fixed in Moralis Server version 0.0.238. Please update your server and let us know if you still experience issues. :raised_hands:

1 Like

Awesome, works now getting the data from the database, thanks

1 Like