Issue with Vue 3 + Nuxt 3 useFetch Data Not Displaying in Template
Background
I’m building an app using Nuxt 3 and Vue 3 (Node v20.18.0). I’m running into a fundamental issue with template reactivity when trying to display data fetched with
useFetch. Specifically:- I can log the data from
inuseFetch
, and the data is correct.<script setup> - However, when binding to the fetched data in the template, the expected reactivity doesn’t occur.
- Some solutions work (like wrapping the data in
), but they feel unnecessary for something as fundamental as this.computed
- Debugging Data Reactivity
- These logs always show the correct data and title values.
- Ensures
is initialized, but this doesn’t fix the template reactivity fordata.value
.data.value.title
- Prevents errors but still doesn’t display the title, even though
confirms it exists.<pre>{{ data }}</pre>
computed- This works, and the title renders correctly when accessed as
.computedData.title
- **Why is template reactivity for `data.value.title` failing?**
- This seems like a fundamental part of Vue’s reactivity system, so I’m not sure why I need
for it to work.computed
- This seems like a fundamental part of Vue’s reactivity system, so I’m not sure why I need
- **Is this an issue with Nuxt’s `useFetch`?**
- Could Nuxt be optimizing reactivity in a way that breaks expected behavior for deep properties?
- **Am I misusing `useFetch`?**
- Is there a better way to fetch data in Nuxt 3 to avoid this issue entirely?
- **Is this a known issue?**
- I couldn’t find documentation addressing this specific behavior. Should I file a bug report?