如果用户已经登录,我想获得电子邮件索赔。
this.auth.idTokenClaims$.forEach(e => console.log(">>>>>>>>>>>>>"+e.email));
正在打印电子邮件
我想写这样的东西(因为e可以为空(
if((this.auth.isAuthenticated$ | async) === false){
this.auth.idTokenClaims$.forEach(e => {
this.cService.dash(e.email).subscribe(
data => { this.yeah = data},
err => console.error(err),
() => console.log('Main Content ')
)}
);
} else {
this.cService.dash(null).subscribe(
data => { this.yeah = data},
err => console.error(err),
() => console.log('Main Content from else '));
}
问题:if((this.auth.isAuthenticated$|async(===false({
它说总是评估为假,因为
此条件将始终返回'false',因为类型为'number'和"boolean"没有重叠。ts(2367(
或
算术运算的左侧必须是"any"类型,"number"、"bigint"或枚举类型。ts(2362(
这些行上的东西
有人能帮我解决这个吗
如果isAuthenticated$
是Observable
或任何类型的Subject
,我会尝试将这两个流构造成pipe
,并执行类似的操作
this.auth.isAuthenticated$.pipe(
skipWhile( isAuthenticated => isAuthenticated),
switchMap( () => this.auth.idTokenClaims$ ),
...
).subscribe()
this.auth.isAuthenticated$.pipe(
skipWhile( isAuthenticated => !isAuthenticated),
switchMap( () => this.cService.dash(null) ),
...
).subscribe()
我的主要观点是,如果你能给出每个有问题变量的类型,那么末尾的$
符号也主要代表Subject
或Observable
,所以我真的不明白forEach在没有订阅的情况下该怎么办