Skip to content
This repository was archived by the owner on Jun 28, 2025. It is now read-only.

Commit 1a0868b

Browse files
author
Manuel Proß
committed
feat(web): add optional chaining
1 parent 079e5bd commit 1a0868b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

web/src/helpers/getPageContent.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export async function getPageContent(slug: string[]) {
1111
},
1212
},
1313
};
14+
1415
const query = qs.stringify(params, { addQueryPrefix: true });
1516
let response, data, page, pageRelation, pageContent;
1617

@@ -31,7 +32,7 @@ export async function getPageContent(slug: string[]) {
3132
}
3233

3334
try {
34-
page = data.data.attributes.items.data.find((item: { attributes: { url: string } }) => item.attributes.url.endsWith(slug[0]));
35+
page = data?.data?.attributes?.items?.data?.find((item: { attributes: { url: string } }) => item?.attributes?.url?.endsWith(slug[0]));
3536
pageRelation = page?.attributes?.page_relation?.data;
3637

3738
if (!pageRelation) {

0 commit comments

Comments
 (0)