I want to add object to the local variable inside promise but the variable is not accessible inside that, here's the code, please focus on the comments "accessible here and not accessible here":
var dfs = [];
var createDFs = function(item, index) {
var country = item._id;
item.country = (countries[0][country.toUpperCase()]);
var findComps = Complete.find({'country': country});
findComps.then(function(comps) {
item.complete = comps;
//dfs.push(item); //doesn't work here
});
dfs.push(item); //works here but item.comps not accessible
};
data.forEach(createDFs);