I am fairly new to NuxtJS and have been following tutorials on it. I am having trouble displaying the {{planet.title}} on my page. However, when I use {{$data}}, I can see all the planets. I want the title of the planet's name that I have in the slug (in this case it is earth but it could be jupiter or mars)
_slug.vue
<template>
<div class="container">
<div>
<NuxtLogo />
<h1 class="title">planet.title here => {{ planet.title }}</h1>
<pre> $data here => {{ $data }}</pre>
</div>
</div>
</template>
<script>
import NuxtLogo from "~/components/NuxtLogo";
export default {
components: {NuxtLogo},
async asyncData() {
const planet = await fetch(
'https://api.nuxtjs.dev/planets'
).then((res) => res.json())
return { planet }
}
}
</script>
<style>
.container {
margin: 0 auto;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
</style>
My Web Page :