NuxtN
Nuxt3y ago
Niklas

useAsyncData typings when using route params

I am using the useAsyncData together with $fetch. I get typings for the data when I have a normal api route (like /api/getdata).
But when I am using route params (like /api/getOtherData/:id) I don't get the typings.

Attachements:
Screenshot 1: types when using :id
Screenshot 2: types when using an template string where the id is replaced:

Is there any way I can keep the typings?

I tried giving the $fetch options like this:
...
$fetch('/api/someOtherData/:id', { params: { id: 'some-id' } })

But params is sadly the same as query so that didn't help :/
image.png
image.png
Was this page helpful?