hmm: Parameter mitgeben beim Express app.get

Beitrag lesen

boar hamma! danke, funktioniert doch. hier der code:

    this.sendClient = function() {
        "use strict";
        var app = this.createApp();
        var port = process.env.port || 8080;
        
        for(var i = 0; i < configJson.routings.length; i++) {
            let x = i;
            var file = configJson.routings[i];
            if(file.sessionSite == 0) {
                app.get(file.route, function(req, res) {
                    console.log(x);
                    res.sendfile(file.htmlFileName, { root: __dirname + file.pathToHtmlFile });
                });
            } else {
                 let x = i;
                app.get(file.route, function(req, res) {
                    console.log(x);
                    if(req.session.email) {
                        res.sendfile(file.htmlFileName, { root: __dirname + file.pathToHtmlFile });
                    } else {
                        var rootFile = configJson.routings[0];
                        res.sendfile(rootFile.htmlFileName, { root: __dirname + rootFile.pathToHtmlFile });
                    }
                });
            }
        }
        
        app.listen(port);
    }