Express.js Cannot read property 'req' of undefined : <p>My Express.js app has been throwing <code>Cannot read property 'req' of undefined</code>. In essence, it listens for a <code>GET</code> request, grab the <code>content</code> query, and then reply with a table. Here's the parts that present the problem.</p>

<p><strong>index.js</strong></p>

<pre><code>var panels = require('./modules/panels.js');
app.get('/panel', function (req, res) {
    var user;
    if (user = req.session.user) {
        panels.getContents(req.query.content, user.innId, res.send);
    } else {
        res.sendStatus(401);
    }
});
</code></pre>

<p><strong>modules/panels.js</strong></p>

<pre><code>exports.getContents = function(panelName, innId, callback) {
    var response = "";
    switch (panelName) {
        case 'tenants':
            con.query(queryString, queryParams, function(err, rows) {
                if (err) {
                    handle(err);
                } else {
                    if (rows.length == 0) {
                        var tenants = 0;
                        var debtors = 0;
                    } else {
                        var tenants = rows[0].tenants;
                        var debtors = rows[0].length;
                    }
                    response = convertToHTMLTable(rows);
                }
                callback(response); /*THE ERROR POINTS HERE */
            });
            break;

        /* other cases here */

        default:
            response += "Invalid Request";
            callback(response);
    }
}
</code></pre>

<p>What did I do wrong? My guess is that I'm not suppose to pass <code>res.send</code> as a callback. So, how can I fix it?</p>
