diff --git a/front/src/pods/equipo/api/equipo.api.ts b/front/src/pods/equipo/api/equipo.api.ts index 1abe2fa..41f9f25 100644 --- a/front/src/pods/equipo/api/equipo.api.ts +++ b/front/src/pods/equipo/api/equipo.api.ts @@ -3,18 +3,30 @@ import { unstable_cache } from "next/cache"; import type { Developer } from "./equipo.api-model"; import { contentIslandClient } from "@/lib"; -export const getDeveloperListCached = unstable_cache( - async (): Promise => { - try { - return await contentIslandClient.getContentList({ - contentType: "developer", - language: "es", - }); - } catch (error) { - console.warn("Warning: developer list not available"); - return []; - } - }, +const fetchDeveloperList = async (): Promise => { + const result = await contentIslandClient.getContentList({ + contentType: "developer", + language: "es", + }); + + if (!result?.length) { + throw new Error("Empty developer list, skipping cache"); + } + + return result; +}; + +const fetchDeveloperListCached = unstable_cache( + fetchDeveloperList, ["developer-list"], { revalidate: 60 } ); + +export const getDeveloperListCached = async (): Promise => { + try { + return await fetchDeveloperListCached(); + } catch (error) { + console.warn("Warning: developer list not available"); + return []; + } +};