feat: Dynamische Hostname- und Portunterstützung für API-Aufrufe implementiert
- Hostname dynamisch aus `window.location.hostname` extrahiert - Port 3000 explizit in der URL ergänzt - Fehler beim Parsen von JSON behoben (404-HTML-Antwort statt JSON) - Verbesserte Fehlerprotokollierung und Debugging-Logs in `useBereicheMarkersLayer.js` - Tooltip-Anzeige für Bereich und Standort optimiert
This commit is contained in:
@@ -48,7 +48,12 @@ const useBereicheMarkersLayer = (map, oms, apiUrl) => {
|
||||
const fetchBereiche = async () => {
|
||||
try {
|
||||
const response = await fetch(apiUrl);
|
||||
const data = await response.json();
|
||||
const text = await response.text(); // Hole die vollständige Antwort als Text
|
||||
console.log("Antwort als Text:", text); // Überprüfe den tatsächlichen Inhalt der Antwort
|
||||
const data = JSON.parse(text); // Versuche, die Antwort zu parsen, falls sie korrektes JSON ist
|
||||
|
||||
console.log("API-URL:", apiUrl);
|
||||
console.log("Response-Status:", response.status);
|
||||
|
||||
const markers = data.map((item) => {
|
||||
const marker = L.marker([item.x, item.y], { icon: customIcon });
|
||||
@@ -103,7 +108,7 @@ const useBereicheMarkersLayer = (map, oms, apiUrl) => {
|
||||
clearInterval(intervalId);
|
||||
};
|
||||
}, [map, bereicheMarkers, oms]);
|
||||
|
||||
/*
|
||||
useEffect(() => {
|
||||
const fetchBereiche = async () => {
|
||||
try {
|
||||
@@ -119,8 +124,8 @@ const useBereicheMarkersLayer = (map, oms, apiUrl) => {
|
||||
// Tooltip
|
||||
marker.bindTooltip(
|
||||
`
|
||||
<strong>locatin_name:</strong> ${item.location_name} <br />
|
||||
<strong> area_name:</strong> ${item.area_name} <br />
|
||||
<strong>Bereich:</strong> ${item.location_name} <br />
|
||||
<strong>Standort:</strong> ${item.area_name} <br />
|
||||
`,
|
||||
{
|
||||
permanent: false,
|
||||
@@ -150,7 +155,7 @@ const useBereicheMarkersLayer = (map, oms, apiUrl) => {
|
||||
};
|
||||
|
||||
fetchBereiche();
|
||||
}, [apiUrl]);
|
||||
}, [apiUrl]); */
|
||||
|
||||
useEffect(() => {
|
||||
if (map) {
|
||||
|
||||
Reference in New Issue
Block a user