hachoter
hachoter
Explore posts from servers
TtRPC
Created by hachoter on 9/19/2023 in #❓-help
Property 'query' does not exist on type ...
I think this is an issue on my end here is how I am defining everything
export const t = initTRPC.create();
export const t = initTRPC.create();
export const assetsRouter = t.router({
images: t.procedure.input(getImagesValidator).query(async ({ input }) => {
return await getImages(input);
}),
});
export const assetsRouter = t.router({
images: t.procedure.input(getImagesValidator).query(async ({ input }) => {
return await getImages(input);
}),
});
import { assetsRouter } from "../apps/routes";
import { t } from "./t";
export const appRouter = t.router({
menus: menusRouter
});
// export type definition of API
export type AppRouter = typeof appRouter;
import { assetsRouter } from "../apps/routes";
import { t } from "./t";
export const appRouter = t.router({
menus: menusRouter
});
// export type definition of API
export type AppRouter = typeof appRouter;
And in my client, I have this
import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
import type { AppRouter } from '../../../api/trpc/server';

export const client = createTRPCProxyClient<AppRouter>({
links: [
httpBatchLink({
url: 'http://127.0.0.1:4000/trpc'
})
]
});
import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
import type { AppRouter } from '../../../api/trpc/server';

export const client = createTRPCProxyClient<AppRouter>({
links: [
httpBatchLink({
url: 'http://127.0.0.1:4000/trpc'
})
]
});
But when I try to query like this client.assets.images.query i get an error property query does not exist, it correctly infers the type assets etc... but not query
6 replies
TtRPC
Created by hachoter on 7/4/2023 in #❓-help
how does batching work?
My understanding is that batching basically combines multiple requests in a single network request, does this require any setup on my end? How does trpc know to wait for another request to batch it together?
6 replies
TtRPC
Created by hachoter on 5/4/2023 in #❓-help
Server side headers are not applied
Hi guys I have the following trpc client initialized
import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
import type { AppRouter } from '../../../api/src/trpc';
import { get } from 'js-cookie';

export const client = createTRPCProxyClient<AppRouter>({
links: [
httpBatchLink({
url: 'http://localhost:8000/trpc',
headers: () => {
return {
authorization: get('authToken')
};
}
})
]
});
import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
import type { AppRouter } from '../../../api/src/trpc';
import { get } from 'js-cookie';

export const client = createTRPCProxyClient<AppRouter>({
links: [
httpBatchLink({
url: 'http://localhost:8000/trpc',
headers: () => {
return {
authorization: get('authToken')
};
}
})
]
});
The problem is that the header doesn't get applied when it's being called on the server, I use a route to authenticate users and I wanna be able to call that from the server as well but I can't figure out how to pass the token, if it would be a regular fetch request I would simply add the cookie but in the callback function I don't have access to the request context, additionally I didn't find a way to add the headers on an individual query only on the client level
2 replies
TtRPC
Created by hachoter on 4/23/2023 in #❓-help
convert the result to date objects
I am not sure if this is even trpcs responsibility but I would like to get my date objects as date objects not strings, the main reason is actually because when I type it on the frontend I am using the prisma client amd it doesn't match up
6 replies