start/assets/js/get_username.js
2024-11-20 18:59:58 -05:00

20 lines
477 B
JavaScript

async function getData() {
const url = "https://login.ami.sc/";
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Response status: ${response.status}`);
}
const user_name = response.headers.get("X-Authentik-Name");
console.log(user_name);
document.getElementById("username").innerHTML = user_name;
} catch (error) {
console.error(error.message);
}
}
getData();