I am creating a chat app in node js using socket.io. When a new user logs in to localhost:3000, a form is given in which you enter your name and room you want to enter. How can i redirect this user to the appropriate room, as soon as submit button is pressed ?
My server by dafault displays login.html when localhost:3000 is connected to, and i want that on clicking submit, a new request is made such that the second app.get
can serve it.
app.get("/", function(req, res) {
res.sendFile(__dirname + "/login.html");
});
app.get("/room", function(req,res) {
res.sendFile(__dirname + "/chat.html");
});
The form in login.html -
var myForm2 = document.getElementById("myForm2");
myForm2.addEventListener("submit", function(e) {
e.preventDefault();
document.location = "localhost:3000/room";
});