Get return type from api route?
Is it possible to get the return type (assuming it's generated by Nuxt) so that I can use it as a type of something else?
Fetch utils know about the return type, but I want to access it directly. How?
4 Replies
Ah took some time to find it. Leaving it here, as it works fine, but maybe someone from core contribs can collaborate if this is the way or there's another approach:
if youre on vscode you can hover the util or composable and right click, then click go to definition and it'll show you the type inside nodemodules, not sure if thats helpful for you
Interesting that you can get the types that way, thanks for following up on your own issue π
I wonder though if it wouldn't be better to create a type/interface inside the API route (or a shared types folder) and explicitly make sure the return value is of that type. Then you wouldn't have to look up the type anywhere else and could import it.
That's usually how I do it too if necessary. But there might be a better way π€
Might be a good topice to raise in the nitro repo