Skip to content

Commit

Permalink
fix(bug): looping and filter on undefined object (#205)
Browse files Browse the repository at this point in the history
* fix: add fallback false

* fix: add null check in subcategory
  • Loading branch information
120EE0692 authored May 22, 2022
1 parent 354b258 commit c5dda85
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions client/src/pages/[category]/[subCategory].jsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export async function getStaticProps({
const subCategoryDetails = ROUTES.SUB_CATEGORIES.OBJECT[
categoryName?.toUpperCase()
]
.filter(({ asyncRoutePath }) => asyncRoutePath === './SubCategory')
?.filter(({ asyncRoutePath }) => asyncRoutePath === './SubCategory')
.filter(({ shortName }) => shortName === subCategory)[0];

if (!subCategoryDetails) {
Expand All @@ -174,7 +174,7 @@ export async function getStaticProps({
} = await GraphClient.query({
query: countOfArticlesBySubCategory,
variables: {
categoryNumber: subCategoryDetails.idNumber,
categoryNumber: subCategoryDetails?.idNumber,
},
});

Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/[category]/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export async function getStaticPaths() {
params: { category: shortName },
}));

return { paths, fallback: true };
return { paths, fallback: false };
}

export default CategoryPage;

0 comments on commit c5dda85

Please sign in to comment.