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 +23
-9
lines changed Expand file tree Collapse file tree 1 file changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -28,21 +28,35 @@ async function getPageProps() {
28
28
const query = qs . stringify ( params , { addQueryPrefix : true } ) ;
29
29
30
30
try {
31
- const response = await fetch ( `${ process . env . CMS_API } /menus/1${ query } ` , {
32
- // headers: {
33
- // authorization: `Bearer ${process.env.CMS_TOKEN}`,
34
- // },
35
- } ) ;
36
-
37
- return ( await response . json ( ) ) . data . attributes . items . data ;
31
+ const response = await fetch ( `${ process . env . CMS_API } /menus/1${ query } ` ) ;
32
+ if ( ! response . ok ) {
33
+ throw new Error ( `Failed to fetch data: ${ response . status } ${ response . statusText } ` ) ;
34
+ }
35
+ const data = await response . json ( ) ;
36
+ return data . data . attributes . items . data ;
38
37
} catch ( error ) {
38
+ console . error ( "Error fetching page props:" , error ) ;
39
39
return [ ] ;
40
40
}
41
41
}
42
42
43
43
export default async function RootLayout ( { children } : { children : React . ReactNode } ) {
44
- const pageProps = await getPageProps ( ) ;
45
- const session = await getServerSession ( ) ;
44
+ let pageProps ;
45
+ let session ;
46
+
47
+ try {
48
+ pageProps = await getPageProps ( ) ;
49
+ } catch ( error ) {
50
+ console . error ( "Error getting page props:" , error ) ;
51
+ pageProps = [ ] ;
52
+ }
53
+
54
+ try {
55
+ session = await getServerSession ( ) ;
56
+ } catch ( error ) {
57
+ console . error ( "Error getting server session:" , error ) ;
58
+ session = null ;
59
+ }
46
60
47
61
return (
48
62
< SessionProvider session = { session } >
You can’t perform that action at this time.
0 commit comments