Been trying to get this code to work for a while now can’t see where I’m going wrong when I try to ‘open with live server’ on visual studio code and inspect the page I can see I’m getting the error:
GET https://txvxu97okj3q.usemoralis.com:2053/server/functions/getNFT?_ApplicationId=hvSK2mZVUIMqGoMT8CJA06NJG8KPEAjrt2ZlLokl&nftId=1 400
and then also,
{code: 141, error: 'httpResponse is not defined'}
code: 141
error: "httpResponse is not defined"
not sure where the error is would greatly appreciate any help 🙂
Moralis.start({ serverUrl: "https://txvxu97okj3q.usemoralis.com:2053/server", appId: "hvSK2mZVUIMqGoMT8CJA06NJG8KPEAjrt2ZlLokl" });
function fetchNFTMetadata(NFTs){
for (let i = 0; i < NFTs.length; i++) {
let nft = NFTs[i];
let id = nft.token_id;
//Call Moralis Cloud function -> Static JSON file
fetch("https://txvxu97okj3q.usemoralis.com:2053/server/functions/getNFT?_ApplicationId=hvSK2mZVUIMqGoMT8CJA06NJG8KPEAjrt2ZlLokl&nftId=" + id)
.then(res => res.json())
.then(res => console.log(res))
}
}
async function initializeApp(){
let currentUser = Moralis.User.current();
if(!currentUser){
current = await Moralis.Web3.authenticate();
}
const options = { address: "0x3be1812365e150157a326a8d0860a72fadee2db0", chain: "rinkeby" };
let NFTs = await Moralis.Web3API.token.getAllTokenIds(options);
console.log(NFTs);
fetchNFTMetadata(NFTs.result);
}
initializeApp();
{code: 141, error: ‘httpResponse is not defined’}