Visit counter not working

Good morning

I tried to create a small js script for a visit counter and it doesn’t work.

Do you have an idea?

https://codepen.io/aaashpnt-the-sans/pen/XWLwaWm

In your codepen the link in this line…

const data = await fetch('https://api.countapi.xyz/hit/cdevl-counter/visits')

…produces this information…

504 Gateway Time-out :rolleyes:

Also codepen will be unable to make head or tales of this…

<script src="index.js" defer></script>

This, of course, begs the question; why are you wanting to
use an inferior javascript method when you a have already
been provided with a working PHP one in this post here…

Visit counter

1 Like

In the tutorial it does this and it works and for me it doesn’t.

Perhaps you could supply a link to your tutorial.

This, at least, will enable members here to
compare it with your codepen version.

1 Like

here is the link

https://www.youtube.com/watch?v=-cd8PFnFFxM

the API server’s dead.

Not much you can do about that if you really want to use that service.

1 Like

FWIW, a dedicated endpoint (external or not) requested from the client side can be useful if you are caching the page responses, where the BE code wouldn’t get executed for each request.

1 Like