SolidJSS
SolidJSโ€ข3y ago
eponymous

Why does routeData() return undefined?

I am fetching data from my Directus backend in createServerData$ like this:

export function routeData() {
    return createServerData$(
        async () => {
            const directus = new Directus('http://localhost:8055')
            return await directus.items('event').readByQuery()
        }
    );
}

export default function Home() {
    const events = useRouteData()
    createEffect(() => {
        console.log(events())
    })

    //...


However, the events variable is always undefined.

I checked that the items are actually being fetched from Directus, and they are. And if I manually return a value from createServerData$ I can access it from the component. So what is going wrong here?

Thanks!
Was this page helpful?