Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

126
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda