Pawieplays
SSR useAsyncData still calling the API in client side?
Yep I understand that, but this is SSR, and not static pages. Our data is pretty dynamic and changes a lot in the CMS side. Before we could do this on Nuxt 2, just using asyncData. It will call the APIs in the server side (without calling it in the client side) before serving the page.
Is this still possible in Nuxt 3?
13 replies
SSR useAsyncData still calling the API in client side?
Hello Alex! I always watch your video. Thank you for responding. Actually yes you are correct. Its an incorrect description.
The API call won't happen again if you visit the page but, when I navigate to another page (first visit), and check the network tab, you could see the API call from our proxied CMS being shown in the dev tools. I guess our goal is to prevent this and for Nuxt to render the page on server side without calling the API in the client side? Is this possible?
13 replies
SSR useAsyncData still calling the API in client side?
Here is our code sample
<script setup lang="ts">
import { metaDesc } from '~/utils/seo'
const nuxtApp = useNuxtApp()
const { data: pageData } = await useAsyncData('homepage', () => useCmsPageQuery('/'), {
getCachedData(key) {
return nuxtApp.payload.data[key] || nuxtApp.static.data[key]
}
})
useHead(metaDesc(pageData?.value?.data?.seo))
</script>
13 replies
useAsyncData dual call issue. One in the client side and server side?
Here is my home page:
<script setup lang="ts">
import { metaDesc } from '~/utils/seo'
const nuxtApp = useNuxtApp()
const { data: pageData } = await useAsyncData('homepage', () => useCmsPageQuery('/'), {
getCachedData(key) {
return nuxtApp.payload.data[key] || nuxtApp.static.data[key]
}
})
useHead(metaDesc(pageData?.value?.data?.seo))
</script>
4 replies