0

I want to save data in accountID and using that ID want to fetch data from another collection but ID is not getting accountID

async function egetCredientials(body){
let accountID =  await getAccuntID(body); 
console.log(accountID);
}

async function getAccuntID(body){
return MongoClient.connect(M_URL, { useUnifiedTopology: true },async function(err, db) {
    if (err) throw err;
    var dbo = db.db("MES");
    c_sClientID = body.sClientID; 
    return await dbo.collection("clients").findOne({_id:c_sClientID}, async function(err, result) {
        if (err) throw err;  
        let allowedEmailID = result.aAllowedEmailAccounts[0];
        // console.log(allowedEmailID);
        return allowedEmailID;
    });  
});
}

0 Answers0