The value being returned from my getStaticProps in nextjs is undefined. I tried fetching data from a graphql endpoint and the return value was undefined when I console.log the value. This is the code block
const graphQuery = new GraphQLClient(url);
export const getStaticProps = async () => {
const { course } = await graphQuery.request(QUERY);
return {
props: {
course,
}
};
};
const CourseList = ({ course }) => {
console.log("course > ", course);
return (
<>
<div></div>
</>
)
};
export default CourseList;
I also tried just declaring a value in getStaticProps and returning it but it still shows undefined when i console log
const graphQuery = new GraphQLClient(url);
export const getStaticProps = async () => {
const course = "Mathematics";
return {
props: {
course,
}
};
};
const CourseList = ({ course }) => {
console.log("course > ", course);
return (
<>
<div></div>
</>
)
};
export default CourseList;
I've run this exact code block on a separate nextjs project and it worked so I'm wondering if something has changed with getStaticProps.