frolicF
Convex Community3mo ago
11 replies
frolic

is there a way to run an action like it were a query?

I want to fetch data from an authenticated, external API endpoint. I can only fetch inside an action, but it seems like useAction only returns a function that I can call and get back a promise (as if it were a mutation). Is there any tooling to allow me to use an action as if it were a query?

I've searched discord and asked AI and seems like maybe the best bet is do wire it up to tanstack query or similar to do the execution of the action inside my component, whatever deduping and client caching I want to do, etc.

I would have expected Convex to provide more tooling around this given the limits of "no fetching in queries". And mirroring all the external API data into my Convex DB doesn't seem like a great solution either.
Was this page helpful?