Tuesday 30 May 2017

how to assign function result to variable in async node js [duplicate]

This question already has an answer here:

want to assign the function result which is in array format to variable. so that i used this variable in async.series function. here is my code

var k = 0;
function query(cb) {
    var mdmid_arr= mdmid_array_implode_array_st[k];
    var my_query = "select sum(cnt_deal_amt) as cnt_deal_amt from crm_clients_feedback_log where cnt_mdm_id IN ("+mdmid_arr+") ORDER BY cnt_mdm_id ASC";
    pool.query(my_query,cb);
}

var result = function(dealerr,dealrslt){
    dealrslt_sa=dealrslt[0].cnt_deal_amt;
    console.log(dealrslt);
    k ++;
    if(k < mdmid_array_implode_array_st.length) {
        setTimeOut(query,0,result);
    }   
}

query(result);

it gives the correct result but not able to assign the result to the variable.



via tanu

No comments:

Post a Comment