Can't access object metadata

Hey guys I have a for loop going here everything logs to console for each NFT before the data was showing with but now in the for loop for some reason I don’t know how to grab the data from the object. If anyone could help would mean a lot thank you! :slight_smile:

await nfts.forEach(function(nft){


                let url = nft.token_uri;

                const params = { theUrl : url }

                const metadata ="fetchJSON", params);



                document.getElementById("nftboyname").innerHTML =;


                document.getElementById("nftboyinfo").innerHTML =;

metadata is coming back as a object promise

Try adding await in front of your and then add async in front of function(nft).

Make your function async and fix this const metadata = await"fetchJSON", params);

I have await in front of const nfts = await Moralis.Web3.getNFTs(); when I add it in front of“fetchJSON”, params); the function does not run

async function nftgallery(){

            const nfts = await Moralis.Web3.getNFTs();



            nft = nft

            let url = nft.token_uri;

            const params = { theUrl : url }

            const metadata ="fetchJSON", params);



            document.getElementById("nftboyname").innerHTML +=;

            //document.getElementById("nftboyinfo").innerHTML =;

            //var pfi2 =

            //document.getElementById("nftboyimage").src = pfi2;



I have 2 awaits in my function and it won’t run when I remove it from await Moralis.Web3.getNFTs(); and add it to“fetchJSON”, params); it does not run but when i remove the first and add it to the cloud run I get back meta is not defined

Did you add async to nfts.forEach(function(nft){ as well? If so, what error do you get?

Yes when I do that and add await to I get Uncaught ReferenceError: nftgallery is not defined for the button im pressing to call the script

How are you calling nftgallery from your button?


like this

<button onclick=“nftgallery()”>NFT GALLERY</button>

sorry the original only posted text like this without the *

I figured out the problem async needed to go here

nfts.forEach(async function(nft){

thanks guys