mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-07-23 04:26:57 +00:00
16 lines
478 B
TypeScript
16 lines
478 B
TypeScript
/**
|
|
* Retrieves tournament data from /api/tournaments/:country
|
|
* @remarks The result is cached for the revalidation period in seconds
|
|
*/
|
|
export default async function getTournaments(country: string) {
|
|
const server = process.env.NEXT_PUBLIC_SITE_URL;
|
|
const res = await fetch(`${server}/api/tournaments/${country}`, {
|
|
next: { revalidate: 300 },
|
|
});
|
|
|
|
if (res.status !== 200) {
|
|
throw new Error("Failed to fetch tournament data");
|
|
}
|
|
return await res.json();
|
|
}
|