I've been struggling to retrieve an image from this API using getStaticProps, but for some reason I can't seem to make it work.
In my code snippet, if I add a question mark like this, the console returns 'undefined'. What could be causing this issue?
<div>
{hotelPics.map((hotelpic)=> (
<Image src={hotelpic.url} />
))}
</div>
Here is the code snippet:
import Image from 'next/image';
import React from 'react'
function Images({hotelPics }) {
console.log(hotelPics);
return (
<div>
{hotelPics.map((hotelpic)=> (
<Image src={hotelpic.url}/>
))}
</div>
)
}
export async function getStaticProps() {
const res= await fetch ('https://obmng.dbm.guestline.net/api/hotels?collection-id=OBMNG')
const hotelPics = await res.json()
return {
props: {
hotelPics,
},
}
}
export default Images