This commit is contained in:
+6
-5
@@ -25,25 +25,26 @@ export async function getLobby() {
|
||||
|
||||
export async function whoami() {
|
||||
const config = useRuntimeConfig();
|
||||
const { data, pending, error, refresh } = await useFetch<User>(
|
||||
const req = await useFetch<User>(
|
||||
config.public.endpoint + "/whoami",
|
||||
{
|
||||
credentials: "include",
|
||||
server: false,
|
||||
}
|
||||
);
|
||||
if (error.value?.statusCode && [401].includes(error.value.statusCode)) {
|
||||
await req.execute();
|
||||
if (req.error.value && req.error.value.statusCode == 401) {
|
||||
// await navigateTo(config.public.discordLoginEndpoint, {
|
||||
// external: true,
|
||||
// });
|
||||
throw new Error("You are not logged in");
|
||||
}
|
||||
if (error.value) {
|
||||
if (req.error.value) {
|
||||
throw new Error(
|
||||
"Something went wrong while trying to get user information"
|
||||
);
|
||||
}
|
||||
|
||||
return data;
|
||||
return req.data;
|
||||
}
|
||||
|
||||
export async function createGame() {
|
||||
|
||||
Reference in New Issue
Block a user