hi all i have this code where i select data from a database and want to insert them as objects inside an array :
conn2.query('SELECT date, action FROM actions WHERE ?', [{
issue_id: data.id
}], function(error, data2) {
if (error) {
showNotification('Error :' + error, 'danger', 'glyphicon glyphicon-tasks');
} else {
data2.forEach(function(data21) {
res.push({
"date": data21.date,
"description": data21.action
});
console.log(res);
});
}
});
the problem is that the res is alwayes empty .... if i
console.log({"date": data21.date,"description": data21.action})
it give me the right object .... seems that the push is not write.
Edited: thanks every body i could't solve this problem so i used officegen which did the job nicely
data2is an empty array, thusres.pushnever gets called? Addconsole.log('data2', data2)to the beginning of the callback function.