Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

271
Vistas
Can't get the data that stored in Redis

I'm trying to create a user after he verified the code that I send him so first I generate the code in sendCode resolver and save it in Redis using setex

the problem is that code is set in Redis but when I try to use it in createUser resolver using get it returns null.

const sendCode: MutationResolvers["sendCode"] = async ({
  input: { phoneNumber, email },
}: {
  input: SendCodeInput;
}) => {
  const code = generate4digitNum();
  await redis.setex(phoneNumber ?? email, THREE_MINS, code);
      return {};
    };



const createUser: MutationResolvers["createUser"] = async ({
  input: { ...userData },
}: {
  input: CreateUserInput;
}) => {
  
  const code = await redis.get(userData.phoneNumber ?? userData.email);
  if (code !== userData.code) {
    throw new Error(errors[0].id);
  }


  user = await userModel.create({ ...userData});

  return {type: user.type, _id: user._id };
};

the redis.ts file that I create:

const client = redis.createClient({
  host: process.env.REDIS_HOST,
  password: process.env.REDIS_PASSWORD,
  port: Number(process.env.REDIS_PORT),
});

client
  .on("connect", function () {
    console.log(`connected ${client.connected}`);
  })
  .on("error", function (error) {
    console.log(error);
  });

export const get: (key: string) => Promise<string> = promisify(client.get).bind(
  client
);

export const setex: (
  key: string,
  seconds: number,
  value: string
) => Promise<string> = promisify(client.setex).bind(client);

I will appreciate any kind of help. Thanks in advance.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda