tRPCttRPC
Powered by
ManthanM
tRPC•3y ago
Manthan

Cannot read properties of undefined (reading 'input')

login: trpc_1.publicProcedure.input(loginInput).mutation((opts) => __awaiter(void 0, void 0, void 0, function* () {
^

TypeError: Cannot read properties of undefined (reading 'input')

#❓-help
I have imported and checked everything but still this error is there



interface loginInput {
  email: string;
  password: string;
}


login: publicProcedure.input(loginInput).mutation(async (opts) => {
    const { input } = opts;
    let user = await prisma.user.findFirst({
      where: {
        email: input.email,
      },
    });

    if (!user)
      throw new TRPCError({ code: "CONFLICT", message: "User Not Found" });

    const compare = await bcrypt.compare(input.password, user.password);

    if (!compare)
      throw new TRPCError({
        code: "FORBIDDEN",
        message: "Enter correct credentials",
      });

    const token = jwt.sign({ userId: user.id }, secret_key);

    return { token };
  }),
interface loginInput {
  email: string;
  password: string;
}


login: publicProcedure.input(loginInput).mutation(async (opts) => {
    const { input } = opts;
    let user = await prisma.user.findFirst({
      where: {
        email: input.email,
      },
    });

    if (!user)
      throw new TRPCError({ code: "CONFLICT", message: "User Not Found" });

    const compare = await bcrypt.compare(input.password, user.password);

    if (!compare)
      throw new TRPCError({
        code: "FORBIDDEN",
        message: "Enter correct credentials",
      });

    const token = jwt.sign({ userId: user.id }, secret_key);

    return { token };
  }),
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Cannot read properties of undefined (reading 'trpc')
fisherFfisher / ❓-help
3y ago
Cannot read properties of undefined (reading 'createTRPCReact')
IndustrialIIndustrial / ❓-help
3y ago
Getting this error: Cannot read properties of undefined (reading 'upsert')
Viszy AVViszy A / ❓-help
3y ago