theturtlechief
TTCTheo's Typesafe Cult
•Created by theturtlechief on 5/5/2023 in #questions
Tailwind quick question?
Awkward div loads in normally and then shrinks. any ideas?
https://recordit.co/6KmKcYsJa3
2 replies
TTCTheo's Typesafe Cult
•Created by theturtlechief on 5/3/2023 in #questions
❌ tRPC failed on profile.getUserByUsername: No "query"-procedure on path "profile.getUserByUsername"
I am a bit lost.
This is the profileRouter.
export const profileRouter = createTRPCRouter({
getUserByUsername: publicProcedure
.input(z.object({ username: z.string() }))
.query(async ({ input }) => {
const [user] = await clerkClient.users.getUserList({
username: [input.username],
});
if (!user) {
// if we hit here we need a unsantized username so hit api once more and find the user.
const users = (
await clerkClient.users.getUserList({
limit: 200,
})
)
const user = users.find((user) => user.externalAccounts.find((account) => account.username === input.username));
if (!user) {
throw new TRPCError({
code: "INTERNAL_SERVER_ERROR",
message: "User not found",
});
}
return filterUserForClient(user)
}
return filterUserForClient(user);
}),
});
and where it's being called.
const ProfilePage: NextPage<{ username: string }> = ({ username }) => {
const { data } = api.profile.getUserByUsername.useQuery({
username,
});
if (!data) return <div>404</div>;
79 replies