30 lines
748 B
TypeScript
30 lines
748 B
TypeScript
export type StreamingServiceRaw = {
|
|
id: number;
|
|
key: string;
|
|
value: string;
|
|
};
|
|
|
|
const STREAMING_SERVICE_API_URL = "http://45.157.177.99:8080/config";
|
|
|
|
export async function getStreamingImages(): Promise<StreamingServiceRaw[]> {
|
|
try {
|
|
const response = await fetch(STREAMING_SERVICE_API_URL);
|
|
if (!response.ok) {
|
|
throw new Error("Network response was not ok");
|
|
}
|
|
const data: unknown = await response.json();
|
|
if (!Array.isArray(data)) {
|
|
console.warn("Expected array, got:", data);
|
|
return [];
|
|
}
|
|
return (data as StreamingServiceRaw[]).map((s) => ({
|
|
id: s.id,
|
|
key: s.key,
|
|
value: s.value,
|
|
}));
|
|
} catch (error) {
|
|
console.error("Fetch error:", error);
|
|
throw error;
|
|
}
|
|
}
|