TestPage: fix: Cannot read property 'trim' of undefined

This commit is contained in:
Dawid Wysokiński 2021-05-28 17:31:05 +02:00
parent aad7f64bfe
commit 46e9e78eaf
1 changed files with 3 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import { GetStaticPaths, GetStaticProps } from 'next';
import { isString, isNil } from 'lodash';
import { polishPlurals } from 'polish-plurals';
import {
createClient,
@ -73,7 +74,8 @@ export const getStaticProps: GetStaticProps<
},
};
if (!params) return { notFound: true, revalidate: REVALIDATE_ERROR };
if (!params || isNil(params.limit) || !isString(params.slug))
return { notFound: true, revalidate: REVALIDATE_ERROR };
const limit = parseInt(params.limit);
const slug = params.slug.trim();
if (