ManthanM
tRPC2y 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 };
  }),
Was this page helpful?