Files
nodeMap/services/webservice/fetchGisLinesStatusService.js
ISA cdca624874 refactor: basePath als Umgebungsvariable eingeführt (NEXT_PUBLIC_BASE_PATH)
- alle festen "/talas5/" Pfade entfernt
- dynamischer basePath für API-Links und Station öffnen
- README.md und CHANGELOG.md aktualisiert
- Version erhöht auf 1.1.188
2025-05-27 11:58:28 +02:00

30 lines
1.1 KiB
JavaScript

// /services/webservice/fetchGisLinesStatusService.js
export const fetchGisLinesStatusService = async () => {
const mode = process.env.NEXT_PUBLIC_API_PORT_MODE;
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
const baseUrl = mode === "dev" ? `${window.location.protocol}//${window.location.hostname}:80${basePath}/ClientData/WebServiceMap.asmx` : `${window.location.origin}${basePath}/ClientData/WebServiceMap.asmx`;
const params = new URLSearchParams(window.location.search);
const idMap = params.get("m");
const url = `${baseUrl}/GisLinesStatus?idMap=${idMap}`;
console.log("📡 fetchGisLinesStatusService URL:", url);
const response = await fetch(url);
if (!response.ok) throw new Error("Fehler beim Laden der Linienstatusdaten");
const text = await response.text();
let json;
try {
json = JSON.parse(text);
} catch (e) {
console.error("❌ Fehler beim JSON-Parsing der Antwort:", text);
throw new Error("Antwort ist kein gültiges JSON");
}
if (!Array.isArray(json.Statis)) throw new Error("Ungültige Antwortstruktur: Statis fehlt");
return json.Statis;
};