T
tRPC

Nextjs http endpoint (no prisma)

Nextjs http endpoint (no prisma)

DDevThoughts4/19/2023
I have simple pages/api/todoEndpint how do i call this endpoint with trcp? I don't want to use prisma?
FFast4/19/2023
Trpc has nothing to do with Prisma i would recommend reading this https://trpc.io/docs And for the endpoint you would have to rewrite it to be defined in the trpc router as a procedure and not a regular nextjs endpoint
DDevThoughts4/19/2023
Thank you! I started to understand: import { z } from "zod"; import { createTRPCRouter, publicProcedure } from "~/server/api/trpc"; const url = "https://jsonplaceholder.typicode.com/todos"; export const exampleRouter = createTRPCRouter({ hello: publicProcedure .input(z.object({ text: z.string() })) .query(({ input }) => { return { greeting: Hello ${input.text}, }; }), getAllTodos: publicProcedure.query(async () => { const res = await fetch(url); const data = await res.json(); return data as Todo[]; }), }); Making a todos route but not getting type completion.
FFast4/19/2023
Does it just not show up on the client? and can you see the hello query?
DDevThoughts4/19/2023
yes, it did show up 🙂 Now i am unsure if this is right way to add types getAllTodos: publicProcedure.query(() => { const data = fetch(url).then( (res): Promise<{ id: number; title: string; completed: boolean }[]> => res.json() ); return data; }),
FFast4/19/2023
Personally I think creating an interface and just casting the json result to it would be the cleanest (Would still have to check if the result of the fetch is correct eg status = 200) almost like how you did it in the first snippet

Looking for more? Join the community!

T
tRPC

Nextjs http endpoint (no prisma)

Join Server
Recommended Posts
Adding clerk auth object to createServerSideHelpersSo I followed clerk's docs for TRPC (https://clerk.com/docs/nextjs/trpc) and I added `auth` to the `Call retries were exceeded with ssgI'm running a `create-t3-app` on Node 18. Has anyone seen errors trying to use SSG with TRPC and PrHow does batching work in SSR & nextjs app directory?I'm currently playing with the app directory for nextjs. If I have a SSR client set up like this: `"This is likely not portable" errorRandomly started getting this weird error on my front end, can't find anything online on it. SomethiIntegrate third-party added endpoints into the router definition?Its would be cool but not too important, so I was wondering whether or not it would be possible to hWhy am I seeing 500 errors on responses to clients in production?I'm running my trpc server with NODE_ENV=production with the expressjs adapter, and I'm getting thistrpc auto refreshes page when I lose focusHi, i thought this was a development environment only configuration, but it does it even in productiIncorrect type errorsNo idea if this is a trpc issue, but i'm having a bit of a nightmare with type errors. Nothing is shtest post 2hello againquery debounceHey there ! I wonder if anyone could point me to a standard recipe to achieve query debouncing and Type of createServerSideHelpers?I'm currently trying to implement a helper for `getServerSideProps` to reduce duplication. It's stilhow to set request timeout in clientcreateProxyClient has no option about timeout like axios does. Just in one router request (query or trpc rate limitinghi I am currently having some problems with a race condition in my TRPC nextJS api. Essentially whtrpc pipe middlewareHey all. I'm currently trying to create a middle ware on endpoints using the new `pipe` API. This Has anyone ever used tRPC (with SSR) and i18n?No matter the lib (next-intl, next-i18n, next-translate), I simply stumble from one problem to anothNew to tRPC and Need Help with BasicsI made a new T3 app, but I don't quite understand how tRPC works, and I would love to get some help web socket keeps on disconnecting and connectingHi! Its my first time using web sockets. The first code snippet is my socket code. The second code sPagination QueryHi, I'm new for web dev and I'm moved to tRPC not so long I'm looking for example of pagination qu