File tree Expand file tree Collapse file tree
front/src/pods/equipo/api Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,18 +3,30 @@ import { unstable_cache } from "next/cache";
33import type { Developer } from "./equipo.api-model" ;
44import { contentIslandClient } from "@/lib" ;
55
6- export const getDeveloperListCached = unstable_cache (
7- async ( ) : Promise < Developer [ ] > => {
8- try {
9- return await contentIslandClient . getContentList < Developer > ( {
10- contentType : "developer" ,
11- language : "es" ,
12- } ) ;
13- } catch ( error ) {
14- console . warn ( "Warning: developer list not available" ) ;
15- return [ ] ;
16- }
17- } ,
6+ const fetchDeveloperList = async ( ) : Promise < Developer [ ] > => {
7+ const result = await contentIslandClient . getContentList < Developer > ( {
8+ contentType : "developer" ,
9+ language : "es" ,
10+ } ) ;
11+
12+ if ( ! result ?. length ) {
13+ throw new Error ( "Empty developer list, skipping cache" ) ;
14+ }
15+
16+ return result ;
17+ } ;
18+
19+ const fetchDeveloperListCached = unstable_cache (
20+ fetchDeveloperList ,
1821 [ "developer-list" ] ,
1922 { revalidate : 60 }
2023) ;
24+
25+ export const getDeveloperListCached = async ( ) : Promise < Developer [ ] > => {
26+ try {
27+ return await fetchDeveloperListCached ( ) ;
28+ } catch ( error ) {
29+ console . warn ( "Warning: developer list not available" ) ;
30+ return [ ] ;
31+ }
32+ } ;
You can’t perform that action at this time.
0 commit comments