I have a method methFirst which is calling another method methSecond, but the problem is that methFirst is getting returned without waiting for methSecond to complete execution -
main method
methMain() {
var result = methFirst();
console.log(result); //undefined
}
first method
methFirst(obj) {
methSecond(obj).then((result) => {
return result;
)};
}
second method
methSecond(obj){
return new Promise((resolve, reject) => {
if(obj == null) {
resolve(true);
}
)};
}
I understand one way of doing this is returning a promise from methFirst but I do want to use it, any help would be appropriated.