I have a function and it does async db search operation.
var get_all_channels = function {
return new Promise(()=> {
db.find({type:'pricing'},{channel_name:1},function(err,docs){
if(err)
return err;
var c = []
docs.forEachOf(function(ch){
c.push(ch['channel_name'])
})
return c;
})
})
}
async function send(){
return await get_all_channels()
}
function calculate(){
send().then(res => alert(res))
}
Here, the above function is not working. I don't know why? Please help me fix this function.