search
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user