Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read properties of null (reading 'attributes') #11

Open
coffeeclubnfts opened this issue Mar 18, 2022 · 9 comments
Open

Cannot read properties of null (reading 'attributes') #11

coffeeclubnfts opened this issue Mar 18, 2022 · 9 comments

Comments

@coffeeclubnfts
Copy link

TypeError: Cannot read properties of null (reading 'attributes') at /Users/timemachine/Downloads/Rarity-Ranking-NFT-main/generator/main.js:38:59 at Array.map (<anonymous>) at generateRarity (/Users/timemachine/Downloads/Rarity-Ranking-NFT-main/generator/main.js:38:26)

I keep getting this error when trying to run the rarity generator.

I tried the repo and watching the tutorial video, ended up with the same problem each time.

Any ideas?
@coffeeclubnfts
Copy link
Author

It works totally fine when testing with the BAYC collection + metadata, wondering if it's something to do with my tokens starting at 1 and not 0? Any way to fix this?

The contract address I'm trying to generate rarity for is:
https://etherscan.io/address/0x68bf5b45eb1851ed543c757c8dbef352be570cb7#code

@boshjerns
Copy link

i am stuck here as well - I hope moralis reaches out about this

@JVmano
Copy link

JVmano commented Mar 25, 2022

Apparently some collections cause this issue on Moralis like Invisible Friends, Cryptopunks V3, Pepe Universe and some others.

@boshjerns
Copy link

let metadata = allNFTs.map((e) => {console.log(JSON.parse(e.metadata).attributes)});

where do you toss that in

@raddad88
Copy link

raddad88 commented Apr 13, 2022

sorry, use this instead

let collection = allNFTs.map(e => {
return {
metadata: JSON.parse(e.metadata),
token_id: e.token_id
};
});

let metadata = collection.map(e => e.metadata);
console.log(metadata.length);

for (let i = 0; i < metadata.length; i++) {
console.log(metadata[i]?.attributes, i);
}

@boshjerns
Copy link

what lines do you add that to/ replace

@raddad88
Copy link

you would replace the line with

let metadata = allNFTs.map((e) => JSON.parse(e.metadata).attributes);

with

let collection = allNFTs.map(e => {
return {
metadata: JSON.parse(e.metadata),
token_id: e.token_id
};
});

let metadata = collection.map(e => e.metadata);
console.log(metadata.length);

for (let i = 0; i < metadata.length; i++) {
console.log(metadata[i]?.attributes, i);
}

@boshjerns
Copy link

running into this now:

let nftTraits = metadata[i].map((e) => e.trait_type);
^

TypeError: metadata[i].map is not a function

appreciate your help a ton

@raddad88
Copy link

where is this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants