Fetch data with custom logic
If you have custom fetching logic, you can wrap the logic inside useAsyncData
.
Just like useFetch
, useAsyncData
will make sure the same data don't have to be refetched again on the client side.
const { data } = await useAsyncData('post-list', () => {
return getPostList()
})
Unlike useFetch
, you need to provide a cache key (post-list
in the above example).