I am using the Moralis API in a project of our company. I need to fetch all the NFTs from a given wallet address on a particular chain using the getNFTs function. But it is taking much time to fetch NFTs and also while fetching some NFTs, 404 error occurs.
- There are 76 Nfts to be fetched. But it takes almost 1 mins to fetch all of those.
- Also within 76, some NFTs could not be fetched due to 404 error.
Is there any way to speed up and avoid this errror?
Here is my code.
const fetchNFTsUtils = async (data) => {
let results = []
for (const d of data) {
if (d.token_uri) {
let url = fixUrl(d.token_uri)
try {
let res = await fetch(url)
.then(res => res.json())
.catch(err => null)
if (res && (res.name || res.image || res.id || res.description)) {
results.push(res)
}
} catch (error) { }
}
}
return results
}
let response = await Moralis.Web3API.account.getNFTs( { chain: chain, address: wa.address } )
let results = await fetchNFTsUtils(response.result)