Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

123
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!