iamshaunjp / nuxt-3-tutorial

All course files for the Nuxt 3 course on Net Ninja Pro and the Net Ninja YouTube channel.
118 stars 65 forks source link

The backend uses FastAPI, and the returned data is right, but cannot get data in NUXT 3 #3

Open Rhin0cer0s2022 opened 1 year ago

Rhin0cer0s2022 commented 1 year ago

My backend uses FastAPI, API return data like:

{"posts":
[
{"id":4370,"title":"cute-bar-2","date":"2023-03-02","tags":"{color-pages,archive,bears}"},
{"id":854,"title":"bat-12","date":"2023-03-01","tags":"{color-pages,archive,bats}"},
...
],
"page":1,
"page_size":20,
"total_pages":232
}

script:

<script setup>
const { data: colorpages } = await useFetch('http://localhost:8000/color-pages')
</script>

return:

RefImpl {                                                                                                                                       
  __v_isShallow: false,
  dep: undefined,
  __v_isRef: true,
  _rawValue: null,
  _value: null
}

<NuxtLink :to="`/colorpages/${p.id}`">{{p.title}}</NuxtLink> page no rendered

But in FastAPI http://127.0.0.1:8000/docs, data return is right

HOW SHOULD I DO? please