29 lines
1.2 KiB
JavaScript
29 lines
1.2 KiB
JavaScript
// /redux/api/fromWebService/fetchGisStationsStatic.js
|
|
// z.B. http://192.168.10.33/talas5/ClientData/WebServiceMap.asmx/GisStationsStatic?idMap=12
|
|
const apiBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL;
|
|
|
|
export const fetchGisStationsStatic = async () => {
|
|
try {
|
|
const params = new URLSearchParams(window.location.search);
|
|
const idMap = params.get("idMap") || process.env.NEXT_PUBLIC_DEFAULT_ID_MAP || "12";
|
|
const idUser = params.get("idUser") || process.env.NEXT_PUBLIC_DEFAULT_ID_USER || "484";
|
|
const response = await fetch(`${apiBaseUrl}/GisStationsStatic?idMap=${idMap}`);
|
|
|
|
//console.log("📡 API Response Status:", response.status);
|
|
//console.log("📡 API Response Headers:", response.headers.get("content-type"));
|
|
|
|
const text = await response.text();
|
|
console.log("📡 API Response Text von fetch:", text);
|
|
console.log("📡 API Response response von fetch:", response);
|
|
|
|
if (!response.ok || !response.headers.get("content-type")?.includes("application/json")) {
|
|
throw new Error("❌ Fehler: Antwort ist kein gültiges JSON");
|
|
}
|
|
|
|
return JSON.parse(text);
|
|
} catch (error) {
|
|
console.error("❌ Fehler beim Abrufen der GIS Stations Static:", error);
|
|
return null;
|
|
}
|
|
};
|