Skip to content

Commit 15af7ac

Browse files
authored
fix: workaround nuxt 3.1.2 useFetch problems, see nuxt/nuxt#15280 (#15)
* fix: workaround nuxt 3.1.2 useFetch problems, see nuxt/nuxt#15280 * fix: no extra semicolon
1 parent a8c895d commit 15af7ac

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/steps/2.addModules/moduleConfigs.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,16 @@ export const resetDatabase = (databaseUrl?: string) => {
8888
`
8989

9090
const prismaExamplePage = `<script setup lang="ts">
91-
const { data: examples } = useFetch('/api/examples')
91+
/**
92+
* In Nuxt 3.1.2 \`useFetch\` return types are not correctly inferred. In order to workaround this limitation, we sadly need to manually import and type a lof ot things.
93+
*
94+
* As soon as https://github.com/nuxt/nuxt/issues/15280 is closed and released, we can go back to just: \`const { data: examples } = useFetch('/api/examples')\`
95+
* */
96+
import type { Ref } from 'vue'
97+
import { Example } from '.prisma/client'
98+
99+
const { data } = useFetch('/api/examples')
100+
const examples = (data as Ref<Example[] | null>)
92101
</script>
93102
94103
<template>

0 commit comments

Comments
 (0)