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

Commit 41c9e1d

Browse files
author
Manuel Proß
committed
feat(web): check if body is array, add check for headline (required field) in news section
1 parent 7b367ee commit 41c9e1d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

web/src/app/api/[homepage]/route.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ export async function GET() {
2626
return Response.json("Homepage contains no data");
2727
}
2828

29+
if (!Array.isArray(homePageData?.data?.attributes?.body)) {
30+
return Response.json("Body has no content");
31+
}
32+
2933
const newsSections = homePageData.data.attributes.body.flatMap((contentEntry, i) => {
30-
if ("newsCount" in contentEntry) {
34+
if ("newsCount" in contentEntry && "headline" in contentEntry) {
3135
return { index: i, newsCount: contentEntry.newsCount, headline: contentEntry.headline };
3236
}
3337
return [];

0 commit comments

Comments
 (0)