23 lines
627 B
TypeScript
23 lines
627 B
TypeScript
// /services/fetchTDRChartDataById.ts
|
|
|
|
export const fetchTDRChartDataById = async (
|
|
id: number
|
|
): Promise<any[] | null> => {
|
|
const isDev = process.env.NEXT_PUBLIC_NODE_ENV === "development";
|
|
|
|
const url = isDev
|
|
? `http://localhost:3000/CPLmockData/TDR/${id}.json`
|
|
: `${window.location.origin}/CPL?Service/empty.acp&TDR=${id}`;
|
|
|
|
try {
|
|
const response = await fetch(url);
|
|
if (!response.ok)
|
|
throw new Error(`Fehler beim Laden der TDR-Daten für ID ${id}`);
|
|
|
|
return await response.json();
|
|
} catch (error) {
|
|
console.error("❌ Fehler in fetchTDRChartDataById:", error);
|
|
return null;
|
|
}
|
|
};
|