hmm: Auf mysql Result in node.js zugreifen.

Beitrag lesen

direkt in meiner server.js steht das hier

app.get('/getSkillData', function (req, res) {
    if(req.session.email) {
        var sqlite3 = require('sqlite3').verbose();
        var db = new sqlite3.Database('skills.db');

        var data = db.all("SELECT skill as skill,subskill as subskill, name as name, nivau as nivau FROM skill_data where email='" 
            + req.session.email + "' order by name, skill, subskill", function(err, rows) {
            res.type('json');
            res.send(rows);
        });
        db.close();
    }
});

clientseitig rufe ich das dann so auf:

 $.ajax({
            url : "/getSkillData",
            dataType: "JSON",
            type: "GET",
            success: function (data) {
            
            for(var i = 0; i < data.length; i++) {
                addTableRowParam(data[i].name, data[i].skill, data[i].nivau);
            }
            addTableRowParam("", "", "");
            }
        });