adding a display name on auth user

This commit is contained in:
Anton Kupriianov 2025-04-28 14:32:41 -07:00
parent 3307601fbc
commit f15d452782
2 changed files with 40 additions and 16 deletions

View file

@ -13,6 +13,20 @@ function Hero() {
cursor.style.top = `${e.clientY}px`;
}
};
async function fetchUser() {
const res = await fetch("http://localhost:3000/api/current_user", {
credentials: "include", // very important
});
if (res.ok) {
const user = await res.json();
console.log("User display name:", user.displayName);
setUser(user);
} else {
setUser(null);
}
}
fetchUser();
window.addEventListener("mousemove", handleMouseMove);