i'm trying to build a basic visitor counter, it works fine if i refresh the homepage, it count the hit, but if i'm going for example into a post, and then i come back to homepage, the counter doesn't appear anymore, and i need to hard refresh the page to make it visible again.
const countVisit = document.getElementById('count');
updateVisitCount();
function updateVisitCount() {
fetch('https://api.countapi.xyz/hit/flarum.it/visits')
.then(res => res.json())
.then(res => {
countVisit.innerHTML = res.value;
})
}
for sure there's something wrong