tRPCttRPC
Powered by
JoelJ
tRPC•2y ago•
1 reply
Joel

TRPC with MSW

Does anyone have a basic example on how to set up MSW in a React Vite TRPC env?

My main question is, how to use MSW to mock my TRPC requests. In a non TRPC environment my handlers looks like this:
  http.get(`/api/my-svc/foo`, () => {
    return HttpResponse.json(mockedResponse, { status: 200 });
  }),
  http.get(`/api/my-svc/foo`, () => {
    return HttpResponse.json(mockedResponse, { status: 200 });
  }),

But TRPC request looks different than a standard fetch request:
http://localhost:3003/rpc/mysvc.getFooData
http://localhost:3003/rpc/mysvc.getFooData


How do I create a handler to mock this TRPC request?
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

RBAC with tRPC
suhanwSsuhanw / ❓-help
9mo ago
`neverthrow` with tRPC
Answer OverflowAAnswer Overflow / ❓-help
16mo ago
WS with TRPC
acronieAacronie / ❓-help
3y ago