title: How to get a URL parameter in Express?
body: <p>I am facing an issue on getting the value of <code>tagid</code> from my URL: <code>localhost:8888/p?tagid=1234</code>.</p>
  
  <p>Help me out to correct my controller code. I am not able to get the <code>tagid</code> value.</p>
  
  <p>My code is as follows:</p>
  
  <p><code>app.js</code>:</p>
  
  <pre><code>var express = require('express'),
    http = require('http'),
    path = require('path');
  var app = express();
  var controller = require('./controller')({
    app: app
  });
  
  // all environments
  app.configure(function() {
    app.set('port', process.env.PORT || 8888);
    app.use(express.json());
    app.use(express.urlencoded());
    app.use(express.methodOverride());
    app.use(app.router);
    app.use(express.static(path.join(__dirname, 'public')));
    app.set('view engine', 'jade');
    app.set('views', __dirname + '/views');
    app.use(app.router);
    app.get('/', function(req, res) {
      res.render('index');
    });
  });
  http.createServer(app).listen(app.get('port'), function() {
    console.log('Express server listening on port ' + app.get('port'));
  });
  </code></pre>
  
  <p><code>Controller/index.js</code>:</p>
  
  <pre><code>function controller(params) {
    var app = params.app;
    //var query_string = request.query.query_string;
  
    app.get('/p?tagId=/', function(request, response) {
      // userId is a parameter in the url request
      response.writeHead(200); // return 200 HTTP OK status
      response.end('You are looking for tagId' + request.route.query.tagId);
    });
  }
  
  module.exports = controller;
  </code></pre>
  
  <p><code>routes/index.js</code>:</p>
  
  <pre><code>require('./controllers');
  /*
   * GET home page.
   */
  
  exports.index = function(req, res) {
    res.render('index', {
      title: 'Express'
    });
  };
  </code></pre>