Joel
Joel
TtRPC
Created by Joel on 4/16/2024 in #❓-help
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?
2 replies