venego
venego
TtRPC
Created by venego on 5/3/2025 in #❓-help
How do I fetch data conditionally?
I'll try to make the vanilla client work, it gave me some error relating to media type, idk...
13 replies
TtRPC
Created by venego on 5/3/2025 in #❓-help
How do I fetch data conditionally?
I just think the recommended way is more complex than necessary.
13 replies
TtRPC
Created by venego on 5/3/2025 in #❓-help
How do I fetch data conditionally?
I need to fetch inside an event listener and act independently from the UI.
13 replies
TtRPC
Created by venego on 5/3/2025 in #❓-help
How do I fetch data conditionally?
I thought I'd just fetch data from server without having to use React hooks and store the parameters in some state or ref. I might just skip tRPC for this one and do a simple Express GET request, although it makes things inconsistent.
13 replies
TtRPC
Created by venego on 5/3/2025 in #❓-help
How do I fetch data conditionally?
No description
13 replies
TtRPC
Created by venego on 5/3/2025 in #❓-help
How do I fetch data conditionally?
No description
13 replies
TtRPC
Created by venego on 5/3/2025 in #❓-help
How do I fetch data conditionally?
I've changed the client to this:
export const trpcClient = createTRPCClient<AppRouter>({
transformer: superjson,
links: [
httpBatchLink({
url: `${vars.serverAddress}/api/trpc`,
],
});
export const trpcClient = createTRPCClient<AppRouter>({
transformer: superjson,
links: [
httpBatchLink({
url: `${vars.serverAddress}/api/trpc`,
],
});
and used it like so:
const translateSelected = await trpcClient.interactiveSubs.translator.query(
{ text: refs.current.processedWords[state.highlightedWordIdx].word }
);
const translateSelected = await trpcClient.interactiveSubs.translator.query(
{ text: refs.current.processedWords[state.highlightedWordIdx].word }
);
but I got these errors:
code: 'BAD_REQUEST',
[cause]: ZodError: [
{
"code": "invalid_type",
"expected": "object",
"received": "undefined",
"path": [],
"message": "Required"
}
]
code: 'BAD_REQUEST',
[cause]: ZodError: [
{
"code": "invalid_type",
"expected": "object",
"received": "undefined",
"path": [],
"message": "Required"
}
]
Seems like it sends undefined instead of the object I've included~
13 replies
TtRPC
Created by venego on 9/28/2023 in #❓-help
Context is not fully globally accessed? [ probably newbie question ]
Thanks @Lucas Thevenet, that saved my day, I guess reading the docs starting from the top is not that practical before I finish reading it.
7 replies