title: nodejs express middleware function return value
body: <p>I'm using NodeJS and Express, I have the following route and the middleware function isMobile. If I don't use return next(); in the isMobile function, the app gets stuck because NodeJS does not move over to the next function. </p>
  
  <p>But I need the isMobile function to return a value so I can process accordingly in the app.get. Any ideas?</p>
  
  <pre><code>app.get('/', isMobile, function(req, res){
   // do something based on isMobile return value
  });
  
  
  
  function isMobile(req, res, next) {
  
      var MobileDetect = require('mobile-detect');
      md = new MobileDetect(req.headers['user-agent']);
  
      //return md.phone(); // need this value back
  
      return next();
  }
  </code></pre>
  
  <p>Thanks.</p>