Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

201
Visualizações
Calling child component async function in parent is not working

I have a Child component where I check if user is logged in:

    <script>
import { goto } from '$app/navigation';

import { user } from '../sessionStore';
import { supabase } from '../supabaseClient';
import Dashboard from './dashboard.svelte';
import Signin from './signin.svelte';

let loading = false;

async function isLogged() {
    try {
        loading = true;
        const user = supabase.auth.user();

        supabase.auth.onAuthStateChange((_, session) => {
            user.set(session.user);
        });

        let { data, error, status } = await supabase
            .from('users')
            .select('*')
            .eq('id', user.id)
            .single();

        if (error && status !== 406) throw error;

        if (data) {
            goto('/signin');
        }
    } catch (error) {
        goto('/signin');
    } finally {
        loading = false;
    }
}
<p use:isLogged></p>

If I go to this page directly it works but when I call this component in my other pages its not working, in my dashboard I call this component simply by importing it and inserting it in the page:

<Child/>

How can I make this work? Please let me know!

about 4 years ago · Santiago Gelvez
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda