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

118
Vistas
How do I leave a message after success to register, and then wait 2 minutes to redirect page?

I'm trying to build the register page (still in the beginning), and if everything will be ok, I want the client to get a message which shows success, but only after 2 seconds to move to another page. My code sends the success div but doesn't send hi to the client after 2 seconds. What is the problem?

exports.register = (req, res) => {
  
  const { name, email, username, password, passwordConfirm} = req.body;

  if (name === '' || email === '' || username === '' || password === '' || passwordConfirm === '') {
    return res.render('register', {
      failMessage: 'One of the fields or more is empty. Please try again.'
    })
  } else {
    res.render('register', {
      successMessage: 'User registered successfully.'
    });
    return setTimeout( () => {
      res.send('hi');
    }, 2000 );
  }
};

This is the router line:

router.post('/register', authController.register);
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