Data Fetching

Source
This example demonstrates data fetching with Nuxt using built-in composables and API routes.
index.vue
Open docs
<script setup>
const { data } = await useFetch('/api/hello')
</script>

<template>
  <div>
    <p>
      Result of <UKbd
        size="lg"
        value="/api/hello"
      />:
    </p>
    <pre>{{ data }}</pre>
  </div>
</template>
https://data-fetching.example.nuxt.space
Read more in Docs > Getting Started > Data Fetching.
Read more in Docs > Guide > Directory Structure > Server.