JoelJ
tRPC2y 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 });
  }),

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


How do I create a handler to mock this TRPC request?
Was this page helpful?