23 lines
725 B
TypeScript
23 lines
725 B
TypeScript
// /services/fetchAllTDMDataService.ts
|
|
|
|
export const fetchAllTDMDataFromServer = async (): Promise<any[]> => {
|
|
if (typeof window === "undefined") return [];
|
|
|
|
const isDev = process.env.NEXT_PUBLIC_NODE_ENV === "development";
|
|
|
|
const slotRequests = Array.from({ length: 32 }, (_, i) => {
|
|
const url = isDev
|
|
? `/device-cgi-simulator/TDM/slot${i}.json` // ✅ Entwicklung: aus public-Ordner
|
|
: `${window.location.origin}/CPL?Service/empty.acp&TDM=${i}`; // ✅ Produktion
|
|
|
|
return fetch(url)
|
|
.then((res) => (res.ok ? res.json() : null))
|
|
.catch((err) => {
|
|
console.error(`❌ Fehler bei Slot ${i}:`, err);
|
|
return null;
|
|
});
|
|
});
|
|
|
|
return await Promise.all(slotRequests);
|
|
};
|