result = {};
Promise.all(data2.map(async function(subcat) {
await productModel.find({ subcategory_id: subcat._id }, function(err4, data4) {
result.sub_category = subcat;
result.product = data4;
});
return result;
})).then(www => {
var records = util.inspect(www, false, null, true /* enable colors */);
console.log(records);
});
I cannot get the result with new object passed.Please help me.