Async Data and useSeoMeta
Hi, I am currently using Nuxt 3 on my website and I use useSeoMeta to change my meta datas.
When I load my page, the wrong meta data shows up until my request to my API finishes, and when I send a link of a user's page it doesn't display any of the values I got from my API.
Here is my code:
13 Replies
Hi, probably due to the use of "useLazyAsyncData". Have you tried replacing it with a simple "useAsyncData"?
Just tried it but it didn't change a thing :/
Oh.. on my side I use "useAsyncData" to directly fetch my data and then I store it with pinia. And to inject metadata I use "useSeoMeta" with data directly from the store.
I wonder if there is a change in timing/lifecycle wrt. options api (that you use) and composition api (that I use on my side).
That would be smth like:
<script lang="ts" setup>
useSeoMeta({
myStore().title,
ogTitle: myStore().title,
myStore().description,
ogDescription: myStore().description,
})
useAsyncData('route', () => myStore().fetchMyData())
</script>
Well if I'm not wrong I am using composition api, maybe it's because your using a local store
And if you switch to script setup instead of using the setup method?
Nope doesn't change a thing either
you shouldn't use it inside useAsyncdata/useLazyAsyncData
instead, use useSeoMeta outside of the function and utilize the data retrieved from it
I changed it earlier but it doesn't work, except if it wasn't what you meant:
now you shouldn't just call it "route" but actually add a slug or param id or similar to the key ☺️
Even with that change it doesn't work, this thing is driving me crazy
well
you have
server: false
so of course it won't have any info on the server 🙂THe thing is that I do get infos from my server, but when I send a link like this: https://www.neeft.fr/joueurs/C0unt
It doesn't display the name or the description of the user