This commit is contained in:
DevOFVictory
2025-10-23 17:58:16 +02:00
parent 52f2e241a7
commit f21f20a4fd
9 changed files with 566 additions and 108 deletions

View File

@@ -65,3 +65,36 @@ export async function getShows(): Promise<Show[]> {
throw error;
}
}
export async function getShowById(showId: number): Promise<Show | null> {
try {
const apiKey = process.env.EXPO_PUBLIC_API_KEY;
const response = await fetch(`${SHOW_API_URL}/${showId}`, {
headers: {
"Content-Type": "application/json",
"X-API-Key": apiKey ?? "",
},
});
if (!response.ok) {
console.error("Fetch error:", response);
return null;
}
const s: RawShow = await response.json();
return {
id: s.showId,
title: s.title,
description: s.description,
genres: s.genre ? s.genre.split(",").map((g) => g.trim()) : [],
thumbnailUri: s.thumbnailUrl,
bannerUri: s.bannerUrl ?? "",
logoUri: s.logoUrl ?? "",
streamingService: s.streamingServices,
concept: s.concept,
running: s.running,
};
} catch (error) {
console.error("Fetch error:", error);
return null;
}
}