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.
But I need the isMobile function to return a value so I can process accordingly in the app.get. Any ideas?
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();
}
Thanks.