I am new to react and feel this might be a basic question
I am trying to get NFTs of the user wallet and trying to map it.
But I am getting the below error
Server Error Error: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead.
Below is my logic
import Link from 'next/link';
import { useWeb3Context } from '../../context'
import { Web3Button } from '../../components';
import axios from 'axios';
import React, { useEffect, useState } from 'react';
import NFTContainer from '@/components/NFTContainer';
const renderNotConnectedContainer = () => (
<Web3Button/>
);
export const ChooseProductView = async () => {
const { address } = useWeb3Context()
if(!address){
return renderNotConnectedContainer()
}
else{
const nfts = await axios.get(`https://ethereum-api.rarible.org/v0.1/nft/items/byOwner?owner=${address}`);
console.log(nfts.data)
return(
<div className="flex items-center justify-center">
<div className="border-grey md: w-full rounded-xl border sm:max-w-xl md:max-w-2xl">
<div className="flex flex-row justify-between py-2 px-6">
<span className="md:text-md text-left text-sm font-light lg:text-lg">
Address
</span>
<span className="md:text-md truncate pl-4 text-right text-sm font-light lg:text-lg">
{address}
</span>
</div>
<NFTContainer nfts={nfts}/>
</div>
</div>
)
}
};
I am further trying to use map as below
import React from "react";
import NFTCard from "./NFTCard";
const NFTContainer = ({nfts}) => {
return(
<div>
{nfts.map((nft:any, index:any) => (
<NFTCard nft={nft} key= {index}/>
))
}
</div>
)
}
export default NFTContainer
Thanks in advance