docs+refactor: fetchGisStationsStatic API-Aufruf vereinheitlicht
- fetchGisStationsStatic.js verwendet jetzt zentrale Port-Logik über .env.local (NEXT_PUBLIC_API_PORT_MODE) - Map-ID wird direkt aus der URL gelesen (?m=...) - Fehlerprüfung auf JSON-Antwort eingebaut - Doku erstellt: /docs/frontend/redux/api/fromWebService/fetchGisStationsStatic.md - CHANGELOG.md aktualisiert (v1.1.71)
This commit is contained in:
@@ -1,20 +1,21 @@
|
||||
// /redux/api/fromWebService/fetchGisStationsStatic.js
|
||||
|
||||
const apiBaseUrl = `${window.location.origin}/talas5/ClientData/WebServiceMap.asmx`;
|
||||
|
||||
export const fetchGisStationsStatic = async () => {
|
||||
try {
|
||||
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 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 url = `${apiBaseUrl}/GisStationsStatic?idMap=${idMap}`;
|
||||
console.log("🔍 fetchGisStationsStatic - URL:", url);
|
||||
|
||||
const response = await fetch(url);
|
||||
|
||||
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");
|
||||
|
||||
Reference in New Issue
Block a user