簡體   English   中英

如何返回嵌套訂閱?

[英]How can I return a nested subscription?

我有以下嵌套訂閱,我需要返回內部訂閱。 我該怎么做呢?

public updateProfiles(){
    this.afAuth.idToken.subscribe(idToken=>{
      return this.httpClient.post<any>('https:example.com/getData',{
        "token": idToken,
        "np":"hzlNpV1239nOKRTcsVdPG",
        "cp":"M6nKYrSjsnA9v34vfB8oD"
      });
    })

  }

在調用模塊中,我想要this.authService.updateProfiles.subscribe(()=> {做某事});

您應該使其可傳遞。

updateProfiles() {
  this.afAuth.idToken.pipe(
    switchMap(idToken => this.httpClient.post(your stuff))
  ).subscribe(result => console.log(result))
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM