javascript - In es6 I need my promise to return true or false when done -
in es6 need promise return true or false when done
this attempt returns promise , need true or false
return this.isuserauthenticated() .then(() => this.checkifteacherprofileexists());
the return part needs true or false.
this 1 of returns looks like:
isuserauthenticated = (): promise<any> => { return new promise((resolve, reject) => { this.authservice.checkifloggedin().then((isauthuser: boolean) => { resolve(true); }); }); }
your return promise holding true
or false
. have chain .then()
hold boolean.
return this.isuserauthenticated() .then(() => this.checkifteacherprofileexists()) .then(v => console.log(v)); // true or false
regarding comment, see @felixkling's comment - can't that, that's not how promises work.
Comments
Post a Comment