const getInactiveUsers = async (req, res) => { let results = []; const rewards = await Reward.find().distinct('data'); await rewards.map(async (reward) => { const result = await Callback.findOne({ data: reward, }); results.push(result); }); return res .status(400) .json({ success: true, count: results.length, data: results })};
rewards.map(async (reward) => ...)
Promise
await
Promise.all
await Promise.all(rewards.map(async (reward) => { ... }));
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)