Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit 16d4baa

Browse files
committed
Add fallback if params not set
1 parent fef873d commit 16d4baa

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

api/wordpress/_global/getPostTypeStaticProps.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ export default async function getPostTypeStaticProps(
4343
})
4444
}
4545

46+
/* -- Fallback: return error if params missing. -- */
47+
if (!params) {
48+
return {
49+
props: {
50+
...sharedProps,
51+
error: true,
52+
errorMessage: 'An unexpected error occurred'
53+
},
54+
revalidate
55+
}
56+
}
57+
4658
/* -- Handle dynamic archive display. -- */
4759
if (!Object.keys(params).length) {
4860
const {apolloClient, ...archiveData} = await getPostTypeArchive(postType)

0 commit comments

Comments
 (0)