metaplex-foundation / js

A JavaScript SDK for interacting with Metaplex's programs
356 stars 182 forks source link

json field is always null #509

Open mellosti opened 1 year ago

mellosti commented 1 year ago

I followed this guide to create a React app with Vite and metaplex. My code looks like this:

import { Metaplex, Nft, PublicKey } from "@metaplex-foundation/js";
import { connection } from "../config/network";

const METAPLEX = Metaplex.make(connection);
const NFTS_CLIENT = METAPLEX.nfts();

export async function getNFTsByOwner(owner: PublicKey): Promise<Nft[]> {
  const metadatas = await NFTS_CLIENT.findAllByOwner({
    owner: new PublicKey(owner),
  });

  const nftsAndSfts = await Promise.all(
    metadatas.map((metadata) =>
      metadata.model === "metadata" ? NFTS_CLIENT.load({ metadata }) : metadata
    )
  );

  return nftsAndSfts.filter((nft) => nft.model === "nft") as Nft[];
}

However, the json field in Nft is always null, even though jsonLoaded is true. I have included "@metaplex-foundation/js": "^0.19.1", in my package.json. No error in the console.

viandwi24 commented 1 year ago

me too have this error

rohanasif commented 5 months ago

Same here