refactor: Naming-Konventionen für digitaleEingaenge umgesetzt
- digitaleEingaengeMockData.js = strukturierte Datenbasis für Development - digitaleEingaengeAPIHandler.ts = API-Endpunkt zur Auslieferung im Dev - fetchDigitaleEingaengeService.ts = Service zur Umwandlung von window-Variablen - Naming-Schema sorgt für klare Struktur und gute Lernbarkeit
This commit is contained in:
22
services/fetchTDRChartDataByIdService.ts
Normal file
22
services/fetchTDRChartDataByIdService.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
// /services/fetchTDRChartDataByIdService.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/apiMockData/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;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user