Use an async function for `getCachedData`
Hi! I'd like to use an async function for the
getCachedData
option in useAsyncData
(specifically, in useFetch
)
Is that possible? I couldn't get it to work..2 Replies
No, the function result it is not awaited.
What are you trying to do?
I am trying to access the nitro server storage through an api endpoint (which will not result in a network call when executing on the server)
Basically, I want to create a wrapper around useFetch, which will cache an external api response on the server after the first call & then only use the cached value during SSR
I managed to abuse the hell out of useFetch and implemented the functionality by manipulating the request url to use the cache endpoint on the server & fetching the data in the transform callback, which is awaited, if the cached data is not present