here is the full code
const featured = ['0x8df29e0c1217344dcca3266e8062ea189a10250a', '0x357f77a02be5a4a80864297c34aa2f6ef3fdb59a']
useEffect(() => {
LoadUserNFT(featured , true)
.then((items) => {
const Items = items.filter(i => i.filetype !== "video/mp4" && i.filetype !== "video/quicktime")
setNfts(Items.slice(0, 5));
setLoadingState(false)
});
}, []);
const LoadUserNFT = async (userId, polygon) => {
const provider = new ethers.providers.JsonRpcProvider(polygon && process.env.NEXT_PUBLIC_ALL_SECRETPOLY || !polygon && process.env.NEXT_PUBLIC_ALL_SECRET)
const contract = !polygon
? fetchContract(provider)
: fetchContractPoly(provider)
const data = await contract.fetchHisNFTs(userId);
const items = await Promise.all(
data.map(async (i) => {
const tokenUri = await contract.tokenURI(i.tokenId);
const meta = await axios.get(tokenUri);
let owner = await contract.ownerOf(i.tokenId.toNumber())
let price = ethers.utils.formatUnits(i.price.toString(), "ether");
let maxbid = ethers.utils.formatUnits(i.maxBid.toString(), "ether");
let item = {
price,
maxbid,
listed: i.listed,
maxBidder: i.maxBidder.toLowerCase(),
bid: i.bid,
tokenId: i.tokenId.toNumber(),
seller: i.seller.toLowerCase(),
owner,
expiration: i.expiration.toString(),
sold: i.sold,
poster: meta.data.poster?.toString(),
filetype: meta.data.filetype?.toString(),
image: meta.data.image,
name: meta.data.name,
description: meta.data.description,
};
return item;
})
);
return items
}
so what the code does is fetch individual nft of every address i pass in