I'm trying to fetch some data from an Api using the getStaticProps but when I pass it to my component It returns undefined.
Here is the code of the function :
export async function getStaticProps() {
const res = (await fetch("https://links.papareact.com/pyp"))
const data = await res.json()
return{
props :{
info : data
}
}
}
And this is the code of my component :
export default function Home({info}) {
return (
<div>
<Header/>
<Banner/>
<main className='max-w-7xl mx-auto px-8 sm:px-16' >
<section>
<h2 className='text-4xl font-semibold pb-5 pt-6'>Explore NearBy</h2>
{/*Pull data from a server */}
{info.map((item)=> {
console.log(item)
})}
</section>
</main>
</div>
);
}
After console.log I get undefined in the terminal