Unable to easily access properties on `getNftMetadata`response
Closed this issue · 2 comments
Code
const { alchemy } = createAlchemyWeb3(ALCHEMY_URL);
const test = { contractAddress: "0x6688Ee4E6e17a9cF88A13Da833b011E64C2B4203", tokenId: "1" };
const nft = await alchemy.getNftMetadata(test);
console.dir(nft);
Description of Problem
while fetching an NFT, I am trying to access a few properties inside the metadata
property on the response such as external_url
and animation_url
. I realize that these are not standard necessarily (though common), so I cannot expect to receive these as responses all the time.
This interface is currently described by the following interface:
alchemy-web3/src/alchemy-apis/types.ts
Lines 81 to 86 in 5d3985f
As a user I would expect that these non-standard properties would either be listed as optional types on this interface, or to just be jammed into attributes
record (or else some "optional_properties" record of some sort if the attributes
actually usually holds other more standardized data.
@JackCurrie Thanks for filing a well thought-out FR!
I'm currently tackling is part of resolving #99 in the PR: #100. I'm planning on adding the few most common ones like name
and description
. I'm extending changing NftMetadata
to NftMetadata extends Record<string, any>
, which should allow you to access any attributes not listed.
Awesome, thank you @thebrianchen , appreciate the quick response! 👍