I am new to asynchronous callbacks. Following is what i am trying to achieve -
myFunc.prototype.dFunc= function (id) {
var _instance = this;
this.sdk.myMethord(id).then(function (sucessObj) {
return sucessObj;
}, function (error){
//Error handling
});
};
//using return value
function asynCheck(id){
var retVal = test.dFunc(id);
alert("dFunc val"+ retVal);
}
I know this won't work due to asynchronous call. I have tried returning a promise function from dFunc method but always retVal is undefined.
Please let me know for a correct way to achieve this, ie - wait for the asynchronous returns