how to search parameter from URL NodeJs and ExpressJS

时间:2016-02-03 04:00:20

标签: node.js express

http://localhost:9000/?utm_source=facebook&utm_medium=advertising&utm_campaign=jobpost

or

http://localhost:9000/test/?utm_source=facebook&utm_medium=advertising&utm_campaign=jobpost

or

http://localhost:9000/blah/?utm_source=facebook&utm_medium=advertising&utm_campaign=jobpost

How to get and check whether utm_source is in URL or not in NodeJS/Express? I've tried like that but not successful.

app.get('/*', function(req, res){
    if (req.query.utm_source === 'facebook') {
        res.send('1) id: ' + req.query.utm_source);
    } else {
        res.redirect('/blah');
    }
});

0 个答案:

没有答案