Using Candy Machine v2, Candy Machine UI and metaplex-foundation/js.
Following https://solanacookbook.com/references/nfts.html#how-to-get-nft-metadata as my basis, I am trying to get the metadata of the NFT that was just minted by the user.
if (status && !status.err && metadataStatus) {
// manual update since the refresh might not detect
// the change immediately
let remaining = itemsRemaining - 1;
setItemsRemaining(remaining);
setIsActive((candyMachine.state.isActive = remaining > 0));
candyMachine.state.isSoldOut = remaining === 0;
setSetupTxn(undefined);
setAlertState({
open: true,
message: "Congratulations! Mint succeeded!",
severity: "success",
hideDuration: 7000,
});
refreshCandyMachineState("processed");
// CODE TO GET METADATA
const keypair = Keypair.generate();
const metaplex = new Metaplex(props.connection);
metaplex.use(keypairIdentity(keypair));
const nft = await metaplex.nfts().findByMint(mintResult.mintPublicKey);
console.log("NFT: ", nft);
console.log(nft.metadata);
}
The issue I run into is that the nft status is still pending, and nft.metadata is none.