0

I am encountering an issue with Pinata's API (https://api.pinata.cloud/data/pinList) where despite unpining several images and files from my Pinata Cloud account, the API continues to fetch the unpinned data along with the pinned data. This inconsistency is causing discrepancies in the fetched NFTs, and I need assistance in resolving this issue.

for reference i am attaching my code here

    const [nfts, setNFTs] = useState([]);

    useEffect(() => {
        const fetchNFTs = async () => {
            try {
                const response = await axios({
                    method: "get",
                    url: "https://api.pinata.cloud/data/pinList",
                    headers: {
                        'pinata_api_key': pinataApiKey,
                        'pinata_secret_api_key': pinataApiSecret,
                    },
                });
                const pinnedNFTs = response.data.rows.filter(row => row.mime_type === 'image/png'); // Filter by MIME type
                const nftsData = pinnedNFTs.map(row => ({
                    name: row.metadata.name,
                    description: row.metadata.description,
                    image: `https://gateway.pinata.cloud/ipfs/${row.ipfs_pin_hash}`, // Construct the complete image URL
                    externalUrl: row.metadata.external_url,
                }));
                setNFTs(nftsData);
                console.log('nfts data' , nftsData)
                console.log(response.data);
            } catch (error) {
                console.error("Error fetching NFTs:", error);
            }
        };
    
        fetchNFTs();
    }, []);

1 Answer 1

0

Super easy, just add the query ?status=pinned to your url:

url: "https://api.pinata.cloud/data/pinList?status=pinned",

Full reference here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.