document.addEventListener("DOMContentLoaded", () => { fetch("https://wf-search.mpp.agency/fetch-agr-items-rak") .then((response) => response.json()) .then((data) => { const counts = data["location-counter"] || {}; const items = document.querySelectorAll("[data-count-object]"); items.forEach((item) => { const objectName = item.dataset.countObject; if (objectName && counts[objectName] !== undefined) { const count = counts[objectName]; item.textContent = count < 10 ? `0${count}` : count; } }); }) .catch((error) => console.error("Error:", error)); });