vendredi 4 mai 2018

Get methods for same URL with different data passed on in Node/Express

So, I am trying to get different data at different scenarios for the same URL. Here is my code.

1st scenario:

app.get('/upload', function(req, res) {
    res.render('upload', {data: 'a'});
});

2nd scenario:

res.redirect('/upload');
app.get('/upload', function(req, res) {
    res.render('upload', {data: 'b'});
});

However, for some reason, it always executes the 1st scenario. How to prioritize each of the get method for a specific situation?

Aucun commentaire:

Enregistrer un commentaire