kalempster
kalempster
TtRPC
Created by kalempster on 6/9/2024 in #❓-help
Subscription example not behaving like it should
Okay I get it now, in my actual project I was using httpBatchLink and wsLink together insead of splitting them using splitLink that's why the subscription wasn't going off.
export const api = createTRPCClient<AppRouter & WebSocketRouter>({
links: [
splitLink({
condition(op) {
return op.type === "subscription";
},
true: wsLink({
client: wsClient,
transformer: superjson,
}),
false: httpBatchLink({
url: import.meta.env.PROD ? `/trpc` : `http://localhost:3000/trpc`,
transformer: superjson,
}),
}),
],
});
export const api = createTRPCClient<AppRouter & WebSocketRouter>({
links: [
splitLink({
condition(op) {
return op.type === "subscription";
},
true: wsLink({
client: wsClient,
transformer: superjson,
}),
false: httpBatchLink({
url: import.meta.env.PROD ? `/trpc` : `http://localhost:3000/trpc`,
transformer: superjson,
}),
}),
],
});
Thanks for help :)
4 replies
TtRPC
Created by kalempster on 3/4/2023 in #❓-help
Error types in catch block
I'm sorry, mutateAsync is destructured from a mutation
const { mutateAsync } = trpc.shop.buyShopItem.useMutation({
retry: (failCount, error) => {
if (failCount >= 5) return false;
if (error.data?.code == "UNAUTHORIZED") return false;
return true;
},
});
const { mutateAsync } = trpc.shop.buyShopItem.useMutation({
retry: (failCount, error) => {
if (failCount >= 5) return false;
if (error.data?.code == "UNAUTHORIZED") return false;
return true;
},
});
3 replies