javascript - How to call one Promise function from another Promise function in Angular 2? -


i have 1 function returns promise needs call function returns promise:

getuser(): promise<user> {     this.getapiuser().then(result => {         ..do stuff result..         return promise.resolve(result);  // doesn't work     }); }  getapiuser(): promise<user> {     return promise.resolve({ firstname: 'jason' }); } 

i think doesn't work since getuser "return promise.resolve" in context of getapiuser handler. easy in angular 1, instantiate $q object , resolve object wherever needed it. can't figure out equivalent in angular 2/typescript/em6.

any appreciated.

your getuser method doesn't return promise @ all.
when invoke then method on promise returns promise , method needs return:

getuser(): promise<user> {     return this.getapiuser().then(result => {         ..do stuff result..         return result;     }); } 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -