Create Effect not executing
the function getName is working fine and shows the name of the person with id 1 after fetching it from my database but this code doesnt log anything to console not even the debug console.log("running") i did :
6 Replies
i changed the Myperson function like this and it still didnt work how should i modify the function in order for it to work ?
it shows undefined
(the function is working and logging Jhon this time)
it worked this way but I'm pretty sure that this is a low quality code I hope someone would fix it
createResource
is your friend when doing async stuff: https://docs.solidjs.com/reference/basic-reactivity/create-resource
if you want to have a loading state: look at <Suspense/>
https://docs.solidjs.com/reference/components/suspense
createResource
is a very powerful primitive!I tried the following code (with id value 1 to test) but page /myperson shows loading then undefined (even without suspense it doesnt work)
Can u log the result in an effect? Like
createEffect(() => console.log(name()))
Is this a solid start project?
True, should that db-call happen on the server? I m unfamiliar w kysely