SansPapyrus683
SansPapyrus683
TtRPC
Created by SansPapyrus683 on 2/14/2024 in #❓-help
is there a better way to do this?
let query;
let params;
switch (getWhat) {
case "posts":
query = api.user.userPosts;
params = { user: uid, what: "posts", cursor: at };
break;
case "likes":
query = api.user.userPosts;
params = { user: uid, what: "likes", cursor: at };
break;
case "following":
query = api.user.followedPosts;
}

//@ts-ignore
const { data, isPlaceholderData } = query.useQuery(params, {
//@ts-ignore
placeholderData: (prevRes) => prevRes ?? initPosts,
});
let query;
let params;
switch (getWhat) {
case "posts":
query = api.user.userPosts;
params = { user: uid, what: "posts", cursor: at };
break;
case "likes":
query = api.user.userPosts;
params = { user: uid, what: "likes", cursor: at };
break;
case "following":
query = api.user.followedPosts;
}

//@ts-ignore
const { data, isPlaceholderData } = query.useQuery(params, {
//@ts-ignore
placeholderData: (prevRes) => prevRes ?? initPosts,
});
so i have a component that renders a post list according to varying api calls however, this requires the two ts-ignore at the bottom. is there a way to tell ts that the two api calls result in the exact same type?
3 replies
TtRPC
Created by SansPapyrus683 on 11/13/2023 in #❓-help
`useQuery` not working?
No description
14 replies
TtRPC
Created by SansPapyrus683 on 11/13/2023 in #❓-help
trying to understand how this works
so i'm looking at the t3 template that was made for me, and there seems to be a trpc folder that creates the trpc proxy client and such along with server/api which actually defines the method in that case, what's the use for the api route? it seems to me like i'm initialiting trpc twice, basically
2 replies