fetch("/api/buildings") .then((res) => { if (!res.ok) { throw new Error("API Fehler"); } return res.json(); }) .then((buildings) => { buildings.forEach((building) => { const element = document.querySelector( `.building[data-id="${building.id}"]`, ); if (!element) return; let title = element.querySelector("title"); if (!title) { title = document.createElementNS("http://www.w3.org/2000/svg", "title"); element.prepend(title); } title.textContent = building.name; }); }) .catch((error) => { console.error("Buildings API Fehler:", error); });