T
tRPC

cant access trpc endpoints via the browser

cant access trpc endpoints via the browser

TTCI11/7/2022
i'm converting some express endpoints to trpc, and I cant figure out how to access my endpoints via the browser for example http://localhost:3000/trpc/getbytenantid my trpc endpoint
export const ticketServiceRouter = router({
getByTenantId: ticketServiceProcedure.query(async () => {
const repo = createRepo();
const tenantId = '908e2d94-aef7-4ba6-a1a3-2ccec65a1d97';

return await repo.get_by_tenant_id({ tenantId });
}),
});
export const ticketServiceRouter = router({
getByTenantId: ticketServiceProcedure.query(async () => {
const repo = createRepo();
const tenantId = '908e2d94-aef7-4ba6-a1a3-2ccec65a1d97';

return await repo.get_by_tenant_id({ tenantId });
}),
});
i get my data in the frontend no problem.
const tickets = trpc.ticketService.getByTenantId.useQuery();
const tickets = trpc.ticketService.getByTenantId.useQuery();
my express endpoint
export const create = (router: Router) => {
const repo = createRepo();

router.get('/tickets/get_by_tenant_id', async (req, res) => {
// Mocked. Should be extracted from the JWT.
const tenantId = '908e2d94-aef7-4ba6-a1a3-2ccec65a1d97';

const result = await repo.get_by_tenant_id({ tenantId });

res.json(result);
});
export const create = (router: Router) => {
const repo = createRepo();

router.get('/tickets/get_by_tenant_id', async (req, res) => {
// Mocked. Should be extracted from the JWT.
const tenantId = '908e2d94-aef7-4ba6-a1a3-2ccec65a1d97';

const result = await repo.get_by_tenant_id({ tenantId });

res.json(result);
});
express adapter
app.use(
'/getTenantById',
trpcExpress.createExpressMiddleware({
router: ticketServiceRouter,
createContext,
})
);
app.use(
'/getTenantById',
trpcExpress.createExpressMiddleware({
router: ticketServiceRouter,
createContext,
})
);
UUUnknown User11/7/2022
Message Not Public
Sign In & Join Server To View
Kkumard311/8/2022
So with this can i access my trpc endpoints on different webisite by making and api request?
UUUnknown User11/8/2022
Message Not Public
Sign In & Join Server To View
Kkumard311/8/2022
that is what i want , thank you man , one more question do you have any example of trpc-openapi prisma example ?šŸ˜…
UUUnknown User11/8/2022
Message Not Public
Sign In & Join Server To View

Looking for more? Join the community!

T
tRPC

cant access trpc endpoints via the browser

Join Server
Recommended Posts
tRPC without SSRWhen using tRPC with ssr it uses `getInitialProps`, which has kinda of a cool effect in terms how a trpc + expo react native issueDoes anyone know how to solve this? Im not familiar with webpack at all. I’m a junior frontend.Can you chain middlewares in v10?Would I be able to make a rate limit and isAuthed middleware, then put queries behind both middlewarLoad data client-side via react-query while using tRPC with SSRIs there any way to load data client-side when using tRPC? I want my page to be rendered and load daServing clients in another repository?Would it be possible for tRPC to act as a server for clients in another repository and if so how wouWhen not to use tRPC?Is there any scenario when building a mobile and/or a web app with backend that you would not recommBi directional infinite query example with prismaI'm working on a project that is using this pattern, but my `hasPreviousPages` gets blown away when Websockets not sending dataHi, I have a websocket route that doesn't seem to be sending any data I added a setInterval to tesQuery keysHi! I'm super new to TRPC and based on my understanding, TRPC has a thin wrapper around react query.Possible to use tRPC proxy client inside Edge Runtime?Hi, im trying to fetch a route from trpc inside a Vercel Edge Runtime function. Therefore im tryinv10 migration using codemodSo I've been looking at the codemod that helps with transition towards v10 and I haven't been able tSSR and loading indicators - I don't get itGuess I'm missing something here, but unfortunately I'm having a hard time with the docs: in https:/Prefetch forEachHello, I'm trying to prefetch a list of procedures like this ```ts type QueryKeys = { // how to tNextJs middleware broken by tRPCHi, I have a NextJs middleware that is redirecting to the login page. Basically an Auth guard over mCannot read properties of undefined (reading 'query')Hey folks, Updating from v9 to v10. I thought I'm done, no type errors. Launching the app in dev modUpdating from v9 to v10 - how to access react hooks?Hey folks, I'm updating to v10. I replaced @trpc/react@9.27.4 with @trpc/react-query@10.0.0-proxy-beHow to infer the output of a mutation? The current methods appear to be depreciated.I am attempting to export the bellow utility function to use client side to infer an output type thaTrouble inferring the type of a very simple structure of nested routersA very simple router results in an inference error, causing the client to not be able to infer the r