Wip : Lobby

This commit is contained in:
2024-06-13 10:00:29 -04:00
parent 8a3e2babc9
commit 4a56f3ed62
4 changed files with 28 additions and 11 deletions
+10 -6
View File
@@ -25,16 +25,19 @@ export async function getLobby() {
export async function whoami() {
const config = useRuntimeConfig();
const req = useFetch<User>(new URL("/whoami", config.public.endpoint).href, {
credentials: "include",
});
const req = await useFetch<User>(
new URL("/whoami", config.public.endpoint).href,
{
credentials: "include",
}
);
if (
req.error.value?.statusCode &&
[401].includes(req.error.value.statusCode)
) {
await navigateTo(config.public.discordLoginEndpoint, {
external: true,
});
// await navigateTo(config.public.discordLoginEndpoint, {
// external: true,
// });
throw new Error("You are not logged in");
}
if (req.error.value) {
@@ -42,6 +45,7 @@ export async function whoami() {
"Something went wrong while trying to get user information"
);
}
return req.data;
}