18 lines
385 B
JavaScript
18 lines
385 B
JavaScript
fetch("/api/buildings")
|
|
.then((res) => res.json())
|
|
.then((buildings) => {
|
|
buildings.forEach((building) => {
|
|
const element = document.querySelector(
|
|
`.building[data-id="${building.id}"]`,
|
|
);
|
|
|
|
if (!element) return;
|
|
|
|
const title = element.querySelector("title");
|
|
|
|
if (title) {
|
|
title.textContent = building.name;
|
|
}
|
|
});
|
|
});
|