Multiply return types
When having an API and there is multiple return scenarios.
e.g.
How can I on the frontend determine and use types based on the result?
I was hoping something like this would work:
The error i'm getting is something like:
23 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Yes, but then I'm missing out on the free typesafety from Nitro. 😄
I've figured a better solution for me right now is to just use different API's and return a single object.
is there a way to write type safe nitro apis?
without trpc?
i think not we need to share the type between server and client or?
My terminology may be wrong, maybe it's called type inferring, not sure of the name.
yes
but how
the routes are defined on a folder sturcture?
you know trpc?
this solves this problem
works best with zod and prisma so you know what server need was server repsonse full autocompletion for everything input and response
I know what it is, but I haven't tried it. Have you used it with Nuxt?
but i wonder how this will work without trpc
trpc?
GitHub
GitHub - cannap/recipes: Simple Recipe app for learning purpose
Simple Recipe app for learning purpose. Contribute to cannap/recipes development by creating an account on GitHub.
just for testing but found new bugs
on the integration from the nuxt plugin itself
GitHub
Devtools breaks when using it inside a component and some other err...
When using i have this in a component const { $client } = useNuxtApp() const addRecipe = async () => { await $client.recipes.create.mutate(recipe.value) the error is throwing but when i submit s...
Yeah, I'm kinda not liking trying it out. Had so many issues back in the day with Nuxt 2 and GraphQL.
not wanting to go through tooling hell.
the other guy found a way but its weired
I like Nuxt's inferred types. That's enough for me right now.
ok 😄
wait where can i read more about that
so nuxt can create inferred types from an api response?
nvm i will try it
Yeah if you use
/server/api/test.get.ts