NuxtN
Nuxt14mo ago
Tackleberry

API routes with route params not having types

I noticed my API routes only have typings if they do not contain a route param. Is this expected behavior? Is there a way to fix / improve it in the project? The docs don't say anything about it.

Example:
// This api route is typed and will correctly infer Word[]
const words = await $fetch(`/api/words/all`)

// This api route is not typed, IDE can not infer response properties
const word = await $fetch(`/api/words/${route.params.wordId}`)
Was this page helpful?