CodingWithJamal
CodingWithJamal
TtRPC
Created by CodingWithJamal on 10/26/2023 in #❓-help
Disable trpc route cahce?
import { protectedProcedure, router } from "@/lib/trpc/server/trpc";
import { TRPCError } from "@trpc/server";

export const clientRouter = router({
get: protectedProcedure.query(async ({ ctx }) => {
const { id: user_id } = ctx.session.user!;

if (!user_id)
throw new TRPCError({
code: "NOT_FOUND",
message: "No user session found",
});

let { data: client, error } = await ctx.supabase
.from("clients")
.select("*")
.eq("user_id", user_id)
.single();

if (error) {
throw new TRPCError({
code: "BAD_REQUEST",
message: error.message,
});
}

return client;
}),
});
import { protectedProcedure, router } from "@/lib/trpc/server/trpc";
import { TRPCError } from "@trpc/server";

export const clientRouter = router({
get: protectedProcedure.query(async ({ ctx }) => {
const { id: user_id } = ctx.session.user!;

if (!user_id)
throw new TRPCError({
code: "NOT_FOUND",
message: "No user session found",
});

let { data: client, error } = await ctx.supabase
.from("clients")
.select("*")
.eq("user_id", user_id)
.single();

if (error) {
throw new TRPCError({
code: "BAD_REQUEST",
message: error.message,
});
}

return client;
}),
});
I have this code to fetch some data from my db and return it, however if i call the endpoint again, the data is the same even if the db is different? Does trpc cache the old data on new request? If so i dont want this
9 replies