Feat : add login button
This commit is contained in:
+2
-19
@@ -9,29 +9,12 @@ export function subscribe(endpoint: string) {
|
||||
return evtSource;
|
||||
}
|
||||
|
||||
export async function getLobby() {
|
||||
export async function whoami() {
|
||||
const config = useRuntimeConfig();
|
||||
const req = await useFetch<Array<Game>>(config.public.endpoint + "/games", {
|
||||
const req = await useFetch<User>(config.public.endpoint + "/whoami", {
|
||||
credentials: "include",
|
||||
server: false,
|
||||
});
|
||||
// await req.execute();
|
||||
await req.execute();
|
||||
if (req.data.value == null) {
|
||||
throw new Error("Lobby answer is empty");
|
||||
}
|
||||
return req.data as Ref<Game[]>;
|
||||
}
|
||||
|
||||
export async function whoami() {
|
||||
const config = useRuntimeConfig();
|
||||
const req = await useFetch<User>(
|
||||
config.public.endpoint + "/whoami",
|
||||
{
|
||||
credentials: "include",
|
||||
server: false,
|
||||
}
|
||||
);
|
||||
await req.execute();
|
||||
if (req.error.value && req.error.value.statusCode == 401) {
|
||||
// await navigateTo(config.public.discordLoginEndpoint, {
|
||||
|
||||
Reference in New Issue
Block a user