Nuxt/examples/composables/use-async-data/components/CounterExample.vue
Daniel Roe 23546a270c
feat(nuxt): automatically generate unique keys for keyed composables (#4955)
Co-authored-by: Pooya Parsa <pyapar@gmail.com>
2022-07-07 18:26:04 +02:00

20 lines
429 B
Vue

<script setup>
const ctr = ref(0)
const { data, pending, refresh } = await useAsyncData(() => $fetch(`/api/hello/${ctr.value}`), { watch: [ctr] })
</script>
<template>
<div>
{{ data }}
<div class="flex justify-center gap-2">
<NButton :disabled="pending" @click="ctr++">
+
</NButton>
<NButton :disabled="pending" @click="refresh">
</NButton>
</div>
</div>
</template>