I have a composable like this:
export default () => {
const { agent_id } = useRouter()?.currentRoute?.value?.params || {} // https://github.com/nuxt/nuxt/issues/20471
if (!agent_id || !agent_id.startsWith("ag_")){
navigateTo("/agents")
}
else {
return useLazyFetch(`/api/agents/${agent_id}`, {
default:() => ({}),
getCachedData: (key, nuxtApp, ctx) => nuxtApp?.payload?.static?.[key] ?? nuxtApp?.payload?.data?.[key]
})
}
}
On a page/component I do:
<script setup>
definePageMeta({ middleware:['auth'] })
const { data: agent, refresh } = await useAgent()
</script>
Then If I use for example <button @click='refresh()'>Refresh</button> Nothing happens, it doesn't recall the backend.
Is this supposed to work this way? I thought before at least refresh skipped caching. Is there a way to skip cache?