#How to wait for the value from a useAction?

6 messages · Page 1 of 1 (latest)

supple patio
#

I am using useAction with a server action, but when I call the action it is returning a Promise, how do I wait for the Promise and display the result?

supple patio
#

Oh seems like I was supposed to use cache rather than an action, and then I use createAsync calling the cache?

supple patio
#

no, personally I needed to use an action because of CORS, but createAsync answers my original question.

  const check = useAction(checkWhitepaper);
  const result = createAsync(() => check(hostname));
supple patio
#

oh seems like you can also "use server" in cache

supple patio
#

oh you can also do it in an async function and use createResource

#

I am learning so much!