2021-10-11 22:36:50 +00:00
|
|
|
<script setup>
|
2022-03-17 10:47:41 +00:00
|
|
|
const count = ref(1)
|
|
|
|
const { data } = await useFetch(() => `/api/hello/${count.value}`, { params: { token: 123 } })
|
2021-10-11 22:36:50 +00:00
|
|
|
</script>
|
2021-12-23 19:27:08 +00:00
|
|
|
|
|
|
|
<template>
|
2022-03-17 10:47:41 +00:00
|
|
|
<NuxtExampleLayout example="use-fetch" :show-tips="true">
|
|
|
|
<div>
|
|
|
|
Fetch result:
|
|
|
|
<pre class="text-left"><code>{{ data }}</code></pre>
|
|
|
|
<NButton @click="count++">
|
|
|
|
+
|
|
|
|
</NButton>
|
|
|
|
</div>
|
2021-12-23 19:27:08 +00:00
|
|
|
<template #tips>
|
|
|
|
<div>
|
|
|
|
Nuxt will automatically read in files in the
|
|
|
|
<a href="https://v3.nuxtjs.org/docs/directory-structure/server#api-routes" target="_blank">
|
|
|
|
<code>~/server/api</code> directory
|
|
|
|
</a>
|
|
|
|
to create API endpoints. Learn more about
|
|
|
|
<a href="https://v3.nuxtjs.org/docs/usage/data-fetching" target="_blank">data fetching</a>.
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</NuxtExampleLayout>
|
|
|
|
</template>
|