createresource signal return undifined

const fetchUser = async (id) =>
(await fetch(`https://swapi.dev/api/people/${id}/`)).json();
const fetchUser = async (id) =>
(await fetch(`https://swapi.dev/api/people/${id}/`)).json();
const [user] = createResource(1, fetchUser);
console.log(user())
const [user] = createResource(1, fetchUser);
console.log(user())
1 Reply
hannus
hannus13mo ago
plz check user.loading first. When user.loading became false, user will be used as a signal.
Want results from more Discord servers?
Add your server