Files
nodeMap/services/webservice/fetchGisStationsStaticDistrictService.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

37 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// /services/webservice/fetchGisStationsStaticDistrictService.js
/**
* Holt statische GIS-Stationen-Daten für Bezirke.
*
* @returns {Promise<Array>} Liste mit Points[]
* @throws {Error} bei Fehler oder ungültiger Antwortstruktur
*/
export const fetchGisStationsStaticDistrictService = 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 idUser = params.get("u");
const url = `${baseUrl}/GisStationsStaticDistrict?idMap=${idMap}&idUser=${idUser}`;
console.log("📡 fetchGisStationsStaticDistrictService URL:", url);
const response = await fetch(url);
if (!response.ok) {
const message = `❌ Fehler: ${response.status} ${response.statusText}`;
console.error(message);
throw new Error(message);
}
const jsonResponse = await response.json();
if (!jsonResponse?.Points) {
throw new Error("Antwortstruktur ungültig 'Points' fehlt");
}
return jsonResponse.Points;
};