0👍
As stated on the Nuxt documentation:
This hook can only be placed on page components.
That means asyncData
only works on components under pages/
folder.
You have several options:
- You use
fetch
instead. It’s the other asynchronous hook but it’s called from any component. It won’t block the rendering as withasyncData
so the component it will instanciated with empty data first. - You fetch your data from the page with
asyncData
and you pass the result as a prop to your component
<template>
<div>
<Hero />
<Releases :releases="rfhreleases" />
<About />
<Contact />
</div>
</template>
<script>
export default {
async asyncData({ $content, params }) {
const rfhreleases = await $content('releases', params.slug)
.only(['artist'])
.sortBy('createdAt', 'asc')
.fetch()
return {
rfhreleases,
}
},
}
</script>
- [Vuejs]-How to display the binary account image received from msal graph API?
- [Vuejs]-Vue computed property updates without dependency change
Source:stackexchange.com