refactor: Services nach Datenquelle getrennt – webservice/, database/ und utils/ Struktur eingeführt (v1.1.117)
This commit is contained in:
30
services/webservice/fetchGisStationsMeasurementsService.js
Normal file
30
services/webservice/fetchGisStationsMeasurementsService.js
Normal file
@@ -0,0 +1,30 @@
|
||||
// /services/api/fetchGisStationsMeasurementsService.js
|
||||
|
||||
export const fetchGisStationsMeasurementsService = async () => {
|
||||
const mode = process.env.NEXT_PUBLIC_API_PORT_MODE;
|
||||
|
||||
const apiBaseUrl = mode === "dev" ? `${window.location.protocol}//${window.location.hostname}:80/talas5/ClientData/WebServiceMap.asmx` : `${window.location.origin}/talas5/ClientData/WebServiceMap.asmx`;
|
||||
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const idMap = params.get("m");
|
||||
const idUser = params.get("u");
|
||||
|
||||
const url = `${apiBaseUrl}/GisStationsMeasurements?idMap=${idMap}&idUser=${idUser}`;
|
||||
console.log("📡 fetchGisStationsMeasurementsService 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?.Statis) {
|
||||
throw new Error("Antwortstruktur ungültig – 'Statis' fehlt");
|
||||
}
|
||||
|
||||
return jsonResponse.Statis;
|
||||
};
|
||||
Reference in New Issue
Block a user