This repository was archived by the owner on Jun 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
web/src/app/api/[homepage] Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 1
1
import { getNews } from "@/helpers/homepage" ;
2
- import { NewsSection , SingleType } from "@/types/strapi" ;
2
+ import { SingleType } from "@/types/strapi" ;
3
3
4
4
export async function GET ( ) {
5
5
const res = await fetch ( `${ process . env . CMS_API } /home?populate=deep` , {
@@ -20,15 +20,15 @@ export async function GET() {
20
20
}
21
21
22
22
const newsSections = homePageData . data . attributes . body . map ( ( contentEntry , i ) => {
23
- if ( "newsCount" in contentEntry ) return { index : i , news : { headline : contentEntry . headline , newsCount : contentEntry . newsCount } as NewsSection } ;
23
+ if ( "newsCount" in contentEntry ) return { index : i , newsCount : contentEntry . newsCount } ;
24
24
} ) ;
25
25
26
26
for ( const newsSectionEntry of newsSections ) {
27
- if ( ! newsSectionEntry ) break ;
28
- const fetchedNews = await getNews ( newsSectionEntry ?. news . newsCount ) ;
29
- fetchedNews . headline = newsSectionEntry . news . headline ;
27
+ if ( newsSectionEntry ) {
28
+ const fetchedNews = await getNews ( newsSectionEntry . newsCount ) ;
30
29
31
- homePageData . data . attributes . body [ newsSectionEntry . index ] = fetchedNews ;
30
+ homePageData . data . attributes . body [ newsSectionEntry . index ] = fetchedNews ;
31
+ }
32
32
}
33
33
34
34
return Response . json ( homePageData . data . attributes ) ;
You can’t perform that action at this time.
0 commit comments