From ea1f032ffc64d838bfaf4e80bb0c435c0e896acb Mon Sep 17 00:00:00 2001 From: JustTemmie <47639983+JustTemmie@users.noreply.github.com> Date: Wed, 16 Jul 2025 10:47:03 +0200 Subject: [PATCH] feat: implemend fetchMyGuilds() api --- composables/api.ts | 5 +++++ layouts/client.vue | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/composables/api.ts b/composables/api.ts index 1b467a4..220e98f 100644 --- a/composables/api.ts +++ b/composables/api.ts @@ -17,6 +17,10 @@ export const useApi = () => { return await fetchWithApi(`/guilds/${guildId}`); } + async function fetchMyGuilds(): Promise { + return ensureIsArray(await fetchWithApi(`/me/guilds`)); + } + async function fetchChannels(guildId: string): Promise { return ensureIsArray(await fetchWithApi(`/guilds/${guildId}/channels`)); } @@ -85,6 +89,7 @@ export const useApi = () => { return { fetchGuilds, fetchGuild, + fetchMyGuilds, fetchChannels, fetchChannel, fetchMembers, diff --git a/layouts/client.vue b/layouts/client.vue index 46bdf89..26a5ac9 100644 --- a/layouts/client.vue +++ b/layouts/client.vue @@ -95,7 +95,7 @@ const options = [ if (invite.length == 6) { try { const joinedGuild = await api.joinGuild(invite); - guilds?.push(joinedGuild); + guilds.push(joinedGuild); return await navigateTo(`/servers/${joinedGuild.uuid}`); } catch (error) { alert(`Couldn't use invite: ${error}`); @@ -151,7 +151,7 @@ const options = [ } ]; -const guilds: GuildResponse[] | undefined = await fetchWithApi("/me/guilds"); +const guilds = await api.fetchMyGuilds(); function createDropdown() { const dropdown = h(GuildDropdown, { options });