I need to get knex
select query result to a variable.
function getUserPlanDetailsWithOutCb(user_id) {
var dataArr =[];
knex('user_plans').select('*').where({ 'user_id': user_id }).then(function(result) {
result.forEach(function(value) {
dataArr.push(value)
});
//return dataArr;
});
return dataArr;
}
var result = getUserPlanDetailsWithOutCb(12);
I have tried return value outside and inside of the call back in knex
. For above code i got the result as [ ]
For second one (return inside callback)
i got the result as
{
"isFulfilled": false,
"isRejected": false
}