HI Wasiu ,
The problem you are facing is the async behaviour of JavaScript.
when the function
citifmonlineDetail(citi,function(result) {
return result;
}) ;
is called the function directly returns undefined , since the function not containing return statement.
There are two ways to solve
1) simply changing to
var data ;
citifmonlineDetail(citi,function(result) {
data = result;
console.log(data);
}) ;
2) BY using promise
var promise = new Promise(function(resolve) { // do a thing, possibly async, then…
function hello(){
setTimeout(function(){
debugger;
resolve("hello");
},1000)
};
hello();
});
promise.then(function(val){
data = val;
console.log(data);
});