如何解决未处理的承诺拒绝:您在期望流的位置提供了“未定义”使用SwitchMap和类型为Observable的函数
这是我第一次使用rxjs库中的__hash__
。
我猜测此错误消息表示它对我的工作方式不满意。
观察我的class Container:
def __init__(self,data=None):
self.data = data or []
def __repr__(self):
return str(self.data)
x = {a}
print(x) # {[]}
a.data = [0,1,2]
print(x) # {[0,2]}
函数
switchMap
更具体地说,addemail
addemail(form:NgForm){
this.googlerecaptchaservice.verifyinteraction('general_marketing_email_signup')
.subscribe(
(score: any)=>{
console.log(score);
const value = form.value.emailaddform;
this.addemailservice.add_email_to_general_marketing(value)
.subscribe(
(req: any)=>{
console.log('here is the test');
console.log(req);
}
);
});
}
我不明白的是为什么我会收到错误消息。我在做什么错了?
解决方法
SwitchMap
应该返回一个Observable,如下所示修改您的代码
verifyinteraction(action): Observable<any>{
return this.recaptchaV3Service.execute(action).pipe(
switchMap((value: any) => {
const payload = {
token: value
};
return this.http.post(
'http://127.0.0.1:8000/verify/recaptcha',payload
);
}));
}
,
SwitchMap需要一个Observable,因此您需要返回this.http.post
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。