I have a function getPackageName
, and inside this function i defined a promise , i need to save the value of this promise and return the value outside , so whenever i call getPackageName
,it will return promise result value ...
getPackageName(modelName){
let modelReq = new Ext.Promise(function(resolve, reject){
Ext.Ajax.request({
url: `db/code/pkgname?tablename=${modelName}`,
method: 'GET',
callback: function(options, success, response){
if (success){
if (response){
resolve(response);
}
else{
console.log("No response from server");
}
}
});
});
modelReq.then(res){
return res.res
}
}
it's not working as expected , and whenever i call getPackageName
, it will return undefined .
Any help would be appreciated for sure .