I have a process where I create a new user and save it in my database with the following code snippet:
const newUser = new User({
username: userId,
password: pass,
nameOfUser: user_name,
emailOfUser: user_email
);
newUser.save();
res.redirect("/redirectpage");
setTimeout(function(){
res.redirect("/");
},5000);
Upon saving the user, I want to implement a countdown redirect page. It is visually represented like this:
https://i.stack.imgur.com/wc94c.png
Once the 5-second counter reaches 0, the user should be redirected back to the login page, which is the home route. I used setTimeout for this functionality. However, my application crashes and shows errors if I do not comment out res.redirect("/redirectpage").