Skip to content

Commit 55265e9

Browse files
committed
counter update with key
1 parent 97b0f26 commit 55265e9

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

index.html

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,13 +1184,7 @@ <h1 class="footer__title">Nipun</h1>
11841184
</div>
11851185
</footer>
11861186
</main>
1187-
<script>
1188-
function cb(response) {
1189-
console.log(response.value);
1190-
document.getElementById('visits').innerText = response.value;
1191-
}
1192-
</script>
1193-
<script async src="https://api.countapi.xyz/hit/nipunh.github.io/visits?callback=cb"></script>
1187+
<script src="./js/counter.js"></script>
11941188
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@emailjs/browser@4/dist/email.min.js"></script>
11951189
<script src="./js/main.js"></script>
11961190
</body>

js/counter.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
function cb(response) {
2-
console.log(response.value)
3-
document.getElementById('visits').innerText = response.value;
4-
}
1+
const countElement = document.getElementById('count');
2+
3+
fetch('https://api.countapi.xyz/hit/nipunh.github.io/nipunh')
4+
.then(response => response.json())
5+
.then(data => {
6+
countElement.innerText = data.value;
7+
})
8+
.catch(error => {
9+
console.error('Error fetching the count:', error);
10+
});

0 commit comments

Comments
 (0)