I have a site where I want to allow users to submit a single piece of information (for simplicity, let's assume their name). They submit their name, this is sent to the server with a post request, and a unique url is returned for them.
The goal: when users go to mysite.com/their-unique-url, then it takes them to mysite.com/index.html, modified so that their name (stored in a database with their unique url) shows up on the page.
How can I have express redirect users to the index.html and, while doing so, pass a JavaScript variable for index.html to use?
app.get("/:unique", function(req, res){
names.findOne({ 'id' : req.params.unique }, 'name', function (err, name) {
if (err) return console.error(err);
res.redirect('/'); //but I also want to pass 'name' to index.html
});