I expected the giver code to return a string, but it is returning ZoneAwarePromise.
Within the service:
getCoveredPeriod() {
let loanDetails = this.getLoanDetails().toPromise();
loanDetails.then((res: any) => {
const coveredPeriodStart = new Date(
res.coveredperiodstartdate
).toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric',
});
const coveredPeriodEnd = new Date(
res.coveredperiodenddate
).toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric',
});
this.coveredPeriod = `${coveredPeriodStart} to ${coveredPeriodEnd}`;
return this.coveredPeriod;
});
}
Within the component:
coveredPeriod: any;
this.coveredPeriod = this.basicFormsService.getCoveredPeriod()
I was expecting this.coveredPeriod
to be of type string, but I am getting:
ZoneAwarePromise {__zone_symbol__state: true, __zone_symbol__value: undefined}
__zone_symbol__state: true
__zone_symbol__value: undefined
Symbol(Symbol.species): (...)
Symbol(Symbol.toStringTag): (...)
__proto__: Object