target: 'static' ssr: false
I have configured my project with ssg.
If you look at fetch in the official nuxt documentation, it says that fetch is executed when a page is created and cached in the client.
However, when data is fetched from fetch and the corresponding url is accessed, an empty area appears and then the content is filled. This means calling from the client.
How can fetch be executed when page is created and all db data can be seen when url is accessed?
<template>
<div>
{{ testData }}
</div>
</template>
<script>
import { defineComponent, ref, useContext, useFetch } from '@nuxtjs/composition-api'
export default defineComponent({
name: 'Test',
fetchOnServer: false,
setup () {
const testData = ref({})
const { $axios } = useContext()
useFetch(async () => {
testData.value = await $axios.get('https://jsonplaceholder.typicode.com/users/1')
})
return {
testData
}
}
})
</script>
<style>
</style>