Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!