❌ 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>;
Was this page helpful?