Hi everyone,
finishing up chris Bs course on YT how to create your first dapp.
In the last section of NFTs im following his video but get thrown the following error:
it has to do with the ${metadata.name} method in h5; same goes for ${metadata.description} as well as img source with ${fixURL(metadata.image_url)}
the code herefore is
getNFTs = async () => {
console.log("get NFTs");
const nfts = await Moralis.Web3API.account.getNFTs({ chain: 'matic' });
console.log(nfts);
let tableOfNFTs = document.getElementById(tableOfNfts);
if(nfts.result.length > 0){
nfts.result.forEach(n=>{
console.log(JSON.parse(n.metadata));
let metadata = JSON.parse(n.metadata);
let content = `
<div class="card col-md-3">
<img src="#" class="card-img-top" height=300>
<div class="card-body">
<h5 class="card-title">${metadata.name}</h5>
<p class="card-text">DESCRIPTION</p>
<a href="#" class="btn btn-primary">Useless Button</a>
</div>
</div>
`
tableOfNfts.innerHTML += content;
})
}
}
fixURL = (url) => {
if (url.startsWith("ifps")){
return "https://ipfs.moralis.io:2053/ipfs/" + url.split("ipfs://").slice(-1)
}
else {
return url + "?format=json"
}
}
What am i missing? thanks for your help!