const Moralis = require("moralis/node");
const serverUrl = "https://eprfpy1pddiw.usemoralis.com:2053/server"; //Moralis Server Url here
const appId = "LnyEdW1E5FQ1U7bibkVRKL8xi4ohvfrKXdxEIDuk"; //Moralis Server App ID here
Moralis.start({ serverUrl, appId });
const collectionAddress = "0x467a3248a77b3d49fbcc7426cb68e8f519e3dcb4"; //Collection Address Here
const collectionName = "Deneme"; //CollectioonName Here
const chain = "avalanche"
async function generateRarity() {
const options = {
address: "0x467a3248a77b3d49fbcc7426cb68e8f519e3dcb4",
chain: "avalanche",
};
const NFTs = await Moralis.Web3API.token.getAllTokenIds(options);
let allNFTs = NFTs.result;
let metadata = allNFTs.map((e) => JSON.parse(e.metadata).attributes);
console.log(metadata[0]);
};
generateRarity();
I run this code on eth network and it works and show me the attributes of nfts on eth networks. But this code is not working for Avalance network. It gives me an error
let metadata = allNFTs.map((e) => JSON.parse(e.metadata).attributes);
^
TypeError: Cannot read properties of null (reading 'attributes')
Am I doing something wrong? I tried to fix this more then 10 hours and used many contract addresses on avalance but the same code works on eth network but not on avax network.
Any helpp