pano9000
pano9000
NNuxt
Created by Ne0n on 7/25/2024 in #❓・help
useFetch loses type from /server/api after using getCachedData
Hi @Ne0n I am facing a similar issue, where with useFetch inside a component, I am not able to get proper typings - and I also stumbled across this InternalApi type (I think it was mentioned on StackOverflow?) -> but I am still running into issues: Can I ask you, how you used the InternalApi successfully? IWhat I am doing is:
type ApiResponse = InternalApi["/api/v1/myroute"]["get"]
const { data: data } = await useFetch<ApiResponse>("/api/v1/myroute");
type ApiResponse = InternalApi["/api/v1/myroute"]["get"]
const { data: data } = await useFetch<ApiResponse>("/api/v1/myroute");
however Typescript then infers the "data" variable to be of type "globalThis.Ref<any>" 😦 (sorry for threadjacking! but I seem to be in the same boat as you :-D)
3 replies