Struggling to retrieve information from the following API using next.js. Despite my efforts, I keep receiving an 'undefined' response and I am unable to pinpoint the issue. Below is a snippet of the code - any assistance in identifying my mistake would be greatly appreciated.
export async function getServerSideProps(context) {
const res = await fetch(
'https://shazam.p.rapidapi.com/charts/track?locale=en-US&pageSize=20&startFrom=0',
{
method: 'GET',
headers: {
'x-rapidapi-host': 'shazam.p.rapidapi.com',
'x-rapidapi-key': 'my_key',
},
},
);
const data = await res.json();
if (!data) {
return {
notFound: true,
};
}
return {
props: {
data: data,
},
};
}