I have some code bellow trying to get all data with its child but when pushing to array its not working can someone help me ? I sending request from sever to get the child after mapping each data for the object then push to array but always get nothing.
var query = new Promise(function (resolve, reject){
Tcompany.find(template.query, function (err, done){
if(!err){
resolve(done);
} else {
reject("PLEASE CHECK QUERY !");
}
});
});
query.then(function (result){
var resultSize = result.length;
var jsonXls = [];
var companyCounter = 0;
while (companyCounter < resultSize){
jsonXls.push("ASDSADADS");
var profileData = new Promise(function(resolve, reject){
item.profileCerts.map(function (profile, profleIndex){
Tprofile.find({
where: {npwp: profile.npwp}
}, function (err, done){
if(!err){
resolve(done);
} else {
reject("PLEASE CHECK QUERY !");
};
});
});
});
profileData.then(function (profiles){
jsonXls.push("ASDSADSADAS"); // NOT PUSHING THE OBJECT
});
companyCounter++;
}
console.log(jsonXls);
});