-
Notifications
You must be signed in to change notification settings - Fork 116
/
Copy pathlogger.js
30 lines (26 loc) · 873 Bytes
/
logger.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
document.addEventListener("DOMContentLoaded", function () {
async function initLogger() {
const body = {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
clientSecret: "f274a57c-fe8f-4967-9cd7-9b109d339fea",
applicationId: "16cea802-947d-48ff-8761-3fda8350083b",
}),
};
try {
const res = await fetch("https://logger-mocha-six.vercel.app/api/logger/v1", body);
const json = await res.json();
if (res.status === 200) {
document.getElementById("logger").textContent = `Visitors: ${json}`;
} else {
console.error("Error fetching visitors:", json);
}
} catch (error) {
console.error("Error connecting to the API:", error);
}
}
initLogger();
});