tRPC - fetch params
Hello,
how can i pass parameters to the query?
I have tasks that need to be filled directly by an ID coming from a URL address.
const params = useParams() as { id: string };
const tasks = await api.tasks.getProjectTasks.fetch();
export const tasksRouter = createTRPCRouter({
getProjectTasks: protectedProcedure.query(({ ctx: { auth, db } }) => {
const data = db
.select()
.from(tasks)
.where(eq(project.id......))
.limit(5)
.orderBy(desc(tasks.createdAt));
return data;
}),
Solution:Jump to solution
Hello,
how can i pass parameters to the query?
I have tasks that need to be filled directly by an ID coming from a URL address.
...
2 Replies