How can I redirect a user from /page
to /page/:nickname
in Express after they enter a nickname and click submit?
This is my code:
// app.js
app.get("/page", (request, response) => {
response.render("page");
});
app.get("/page/:nickname", (request, response) => {
response.render("page", {
nickname: request.params.nickname
});
});
// page.pug
extends layout
block content
// render when on "/page" and "/page/:nickname"
form(method="post" action="???")
input(placeholder="Player nickname" type="text")
button.btn.btn-success(type="submit")
|Search
if nickname
// render if on "/page/:nickname"