Open Octoping925 opened 1 year ago
getStaticProps function (index.tsx) returns unexpected undefined when it makes Exception.
getStaticProps
undefined
it cause Error: Your getStaticProps function did not return an object. Did you forget to add a return? Error
Error: Your getStaticProps function did not return an object. Did you forget to add a return?
I fixed it like this.
export async function getStaticProps() { try { const posts = await getPosts() const filteredPost = filterPosts(posts) const tags = getAllTagsFromPosts(filteredPost) return { props: { tags: { All: filteredPost.length, ...tags, }, posts: filteredPost, }, revalidate: 1, } } catch (error) { // returns StaticProps about meaning no posts were fetched return { props: { tags: { All: 0, }, posts: [], }, revalidate: 1, } } }
However, I left this bug as an issue without PR because I thought it might have been intended.
yarn dev
Google Chrome
I was having the same issue, it's because the client is making a request to a notion page that is set to private.
Choose whichever option you prefer:
Take care!
Describe the bug
getStaticProps
function (index.tsx) returns unexpectedundefined
when it makes Exception.it cause
Error: Your getStaticProps function did not return an object. Did you forget to add a return?
ErrorI fixed it like this.
However, I left this bug as an issue without PR because I thought it might have been intended.
To reproduce
yarn dev
with no modification of codeBrowser
Google Chrome
Validations