I use a function in the for loop. I can not export the result of the function.
I want to export the result to the data array. How can I do it ?
function opPerformance(callback) {
    var data = [];
    dbConn.connect(function(err) {
        var request = new sql.Request(dbConn);
        request.query('select * from Kullanici ORDER BY Kullanici_Adi ASC ').then(function(recordset) {
            var results = [];
            for (var i in recordset.recordset) {
                data[i] = {
                    kullanici_adi:recordset.recordset[i].Kullanici_Adi,
                    performance:'0'
                };
                opPerformanceData(recordset.recordset[i].Kullanici_Adi, function ( result ){
                    data[i]['performance'] = result; // This is not working, I can not get the end out.
                    console.log(result); // This works.
                });
            }
            callback(data);
        });
    });
};
 
    