I am currently developing a web application using NextJs. On one of the pages, I am trying to make an API call to fetch data and display it. However, during compilation, I encountered an error.
The specific error message is:
Error: Your `getStaticProps` function did not return an object. Did you forget to add a `return`?
Below is the code for my function:
export async function getStaticProps(context) {
try {
const res = await fetch(ApiLinks.players.all)
.then((response) => response.json())
.then((response) => response.data.teamMembers)
const responsePlayers = res.players;
const responseStaff = res.staff;
return {
props: {
responsePlayers,
responseStaff,
}
}
} catch (err) {
console.error(err);
}
}