mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 15:42:09 +00:00
afcaaff57d
Co-authored-by: Daniel Roe <daniel@roe.dev> Co-authored-by: Pooya Parsa <pyapar@gmail.com>
21 lines
706 B
Vue
21 lines
706 B
Vue
<script setup>
|
|
const { data } = await useFetch('/api/hello', { params: { foo: 'bar' } })
|
|
</script>
|
|
|
|
<template>
|
|
<NuxtExampleLayout example="use-fetch" show-tips="true">
|
|
Server response
|
|
<pre class="text-left"><code>{{ data }}</code></pre>
|
|
<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>
|