NuxtN
Nuxt12mo ago
bnason

Nuxt Server Api response data typing with parameters

Is there any way to get a narrowed down type when calling a GET request with parameters? For instance, If I call useFetch(`/api/user/${userId}`) it'll give me the base object and if I want to include extra data like their posts I would call useFetch(`/api/user/${userId}`, { query: { includePosts: true }) and I want that response to be typed to include the includePosts key and that it exists
Was this page helpful?