Mock Dateien für TDM erstellt:
Eine Liste mit den letzten 100 TDR Messungen des Slots
This commit is contained in:
22
services/fetchAllTDMData.ts
Normal file
22
services/fetchAllTDMData.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
// /services/fetchAllTDMData.ts
|
||||
|
||||
export const fetchAllTDMDataFromServer = async (): Promise<any[]> => {
|
||||
if (typeof window === "undefined") return [];
|
||||
|
||||
const isDev = window.location.hostname === "localhost";
|
||||
|
||||
const baseUrl = isDev
|
||||
? "/CPLmockData/TDM" // z. B. /public/CPLmockData/TDM/slot0.json usw.
|
||||
: `${window.location.origin}/CPL?Service/empty.acp&TDM`;
|
||||
|
||||
const slotRequests = Array.from({ length: 32 }, (_, i) =>
|
||||
fetch(`${baseUrl}=${i}`)
|
||||
.then((res) => (res.ok ? res.json() : null))
|
||||
.catch((err) => {
|
||||
console.error(`❌ Fehler bei Slot ${i}:`, err);
|
||||
return null;
|
||||
})
|
||||
);
|
||||
|
||||
return await Promise.all(slotRequests);
|
||||
};
|
||||
Reference in New Issue
Block a user