You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
maettleship/public/scripts/gamePageInfo.js

21 lines
682 B

document.addEventListener('DOMContentLoaded', async () => {
const playerInfoDiv = document.getElementById('playerInfo');
try {
const response = await fetch('/user-info', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
});
if (response.ok) {
const userInfo = await response.json();
playerInfoDiv.textContent = `Logged in as: ${userInfo.pseudo}`;
} else {
playerInfoDiv.textContent = 'Error: Could not retrieve user information.';
}
} catch (error) {
playerInfoDiv.textContent = `Error: ${error.message}`;
}
});