0
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.

namgold
  • 1,009
  • 1
  • 11
  • 32
  • Does this answer your question? [How do I return the response from an asynchronous call?](https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – Liam Sep 25 '20 at 10:50
  • Please add your title is more accurate about your certain problem. – sorosh_sabz Sep 25 '20 at 12:14

0 Answers0