Is this waste of space?

Hello lets say I have router
export const coinRouter = router({
getCoin: publicProcedure
.input(z.object({ name: z.any()}))
.query(async ({ input }) => {
const coin:Coin = await fetch(`https://api.coingecko.com/api/v3/coins/${input.name}`).then(res =>
res.json());
return coin
}),
})
export const coinRouter = router({
getCoin: publicProcedure
.input(z.object({ name: z.any()}))
.query(async ({ input }) => {
const coin:Coin = await fetch(`https://api.coingecko.com/api/v3/coins/${input.name}`).then(res =>
res.json());
return coin
}),
})
And I get big chunk of data BUT I am using only a part of this big data. Can I get only the stuff that I am interested in?
4 Replies
cje
cje2y ago
between your app and the api you're talking to, depends on the api between your backend and your frontend, yea sure, just dont send all of it
noctate
noctate2y ago
yeah but how can I do that... I mean i dont know syntax oh wait I guess I found what I was looking for
noctate
noctate2y ago
Total TypeScript
Verify Unknown APIs with an Object Schema
Zod is a TypeScript-first schema declaration and validation library. In this tutorial, Matt Pocock has prepared a set of exercises that will help you level up.
noctate
noctate2y ago
It bothered me for a really long time
Want results from more Discord servers?
Add your server