<script>
document.addEventListener('DOMContentLoaded', function() {
fetchUserData();
});
function fetchUserData() {
const apiUrl = 'https://game-mate.onrender.com/api/user/login';
fetch(apiUrl, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + localStorage.getItem('token')
}
})
.then(response => response.json())
.then(data => {
if (data && data.username) {
document.getElementById('welcomeMessage').textContent = 'Welcome, ' + data.username + '!';
}
})
.catch(error => {
console.error('Error fetching user data:', error);
});
}
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
</body>
The problem : In the page even after logging in the user name isn’t showing in the page… I want some help…pls be fast…I have tried many things but I can’t resolve this issue…
New contributor
Soham Pal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.