I might be wording the question incorrectly...
I'm trying to make a url shortener using Node.js, Express, MongoDB (mongoose).
I've set it so that when the user loads the home page, they are redirected to the home page.
// horribly designed home page
app.get('/', function(req, res){
res.render('index');
res.end();
});
This part works. The user successfully sees the home page.
But then, I also have the following code:
// redirects to corresponding url
app.get('/:digits', function(req, res){
console.log('getting full url from database');
}
Every time the user navigates to the home page (/), this path is also triggered and I see the 'getting full url from database' in the console.
Why is this?