I am using Alchemy API to handle fetching NFTs and their metadata in my platform. It has valuable methods, such as retrieving all issued NFTs of a collection or all owned NFTs of an address within a specified network.
However, I need to get the NFTs that a specific address owns from a target NFT collection. Is there a solution to this in Alchemy docs ( since I did not find it )? Or do I have to filter Alchemy's response by the Javascript filter( ) method?
This is the script I am using for this purpose.
const [ nfts, setNfts ] = useState(null)
const settings = {
apiKey: 'Alchemy API Key',
network: Network.MATIC_MAINNET,
};
const alchemy = new Alchemy(settings);
useEffect(() => {
fetchNfts()
}, [])
const fetchNfts = async () => {
console.log("Fetching NFTs ...");
const response = await alchemy.nft.getNftsForContract("0x220A95bdE3ffa364050FFe07b436869C08787eC8");
setNfts(response.nfts);
}