SolidJSS
SolidJSโ€ข3y agoโ€ข
14 replies
Mathieu

How to await on the Resource's promise?

Say users is a resource (from createResource). I would like to await for the underlying promise to complete. How could I acheive this?
const fetchUser = async (userId: string) => {
  const [users] = useUsers(); // users is built with createResource
  await users.???; // how to await the underlying promise?
  return users().find(({ id }) => id === userId);
};
Was this page helpful?