diff --git a/components/profile/ProfileInformation.vue b/components/profile/ProfileInformation.vue index 9254ce8..20f0386 100644 --- a/components/profile/ProfileInformation.vue +++ b/components/profile/ProfileInformation.vue @@ -6,7 +6,6 @@ const {user, loading, error, fetchUser} = useUser() onMounted(async () => { if (session.value) { await fetchUser() - console.log(user.value) } }) diff --git a/composables/useUser.ts b/composables/useUser.ts index 7f997cb..d068454 100644 --- a/composables/useUser.ts +++ b/composables/useUser.ts @@ -1,23 +1,23 @@ import type {GetUserResponse} from "@/types/api/users"; export const useUser = () => { - const user = useState('user', () => null) + const user = useState('user', () => null) const loading = useState('userLoading', () => false) - const error = useState('userError', () => null) + const error = useState('userError', () => null) const fetchUser = async () => { - // Only fetch if we don't have user data - if (!user.value) { - loading.value = true - error.value = null - try { - user.value = await useProfileInformation() - } catch (err) { - error.value = 'Failed to fetch user' - console.error(err) - } finally { - loading.value = false + try { + // Only set loading on initial fetch + if (!user.value) { + loading.value = true } + + user.value = await useProfileInformation() + } catch (err) { + error.value = 'Failed to fetch user' + console.error(err) + } finally { + loading.value = false } }