What could go wrong using top-level await useFetch in a page?
=> /pages/index.vue
<script setup>
const { data } = await useFetch('/api/v1/posts');
</script>
=> /server/api/v1/posts/index.ts
export default defineEventHandler(async () => {
const results = await prisma.posts.findMany();
return results;
});
On first page visit I will have null posts. Why is useFetch not blocking page rendering until server has been responded? :/
<script setup>
const { data } = await useFetch('/api/v1/posts');
</script>
=> /server/api/v1/posts/index.ts
export default defineEventHandler(async () => {
const results = await prisma.posts.findMany();
return results;
});
On first page visit I will have null posts. Why is useFetch not blocking page rendering until server has been responded? :/
