亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

從服務器發送請求的合并映射錯誤

從服務器發送請求的合并映射錯誤

呼喚遠方 2022-01-13 15:19:42
我有一個角度應用程序,我正在通過服務調用進行發布請求。但我得到一個錯誤。但是服務調用會發送請求。所以這是一個非常具有誤導性的錯誤。這是我的方法:sendEcheq(patientId: string) {    if (this.sendEcheq.length > 0) {      of(this.echeqsToSend)        .pipe(          mergeMap(echeqsToSend =>            forkJoin(              echeqsToSend.map((echeqFamily) =>                this.echeqSubmissionMedicalService.createSubmissionBatch(1,   {                  echeqFamilies: [                    echeqFamily.family                  ],                  participants: [                   patientId                  ]                }).subscribe(result => {                  console.log(result);                })              )            )          )        )        .subscribe(          result => {            this.dialog.close();            this.snackBar.open('De vcheq(s) zijn verstuurd', 'Ok');          },          error => {            console.error('Server error when assigning vcheq', error);            this.snackBar.open('Er ging iets mis bij het opsturen, probeer het later nog een keer', 'Ok');            this.dialog.close();          }        );    }  }因此,如果我執行 service methdod: createSubmissionBatch 那么它可以工作。但我仍然收到此錯誤:echeq-selector.component.ts:89 Server error when assigning vcheq TypeError: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.    at subscribeTo (subscribeTo.js:41)    at subscribeToResult (subscribeToResult.js:11)    at new ForkJoinSubscriber (forkJoin.js:42)    at Observable._subscribe (forkJoin.js:28)    at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe (Observable.js:43)    at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe (Observable.js:29)    at subscribeTo.js:21當然,我首先搜索了這個錯誤。但我只發現與其他東西相關的andswares
查看完整描述

1 回答

?
撒科打諢

TA貢獻1934條經驗 獲得超2個贊

您返回的是 aSubscription而不是流,因為您有一個.subscribe打印結果的內部。


您應該將結果通過管道傳遞給tap操作并在那里打印,因為tap不會修改返回的流。


sendEcheq(patientId: string) {

  if (this.sendEcheq.length > 0) {

    of (this.echeqsToSend)

    .pipe(

      mergeMap(echeqsToSend =>

        forkJoin(

          echeqsToSend.map((echeqFamily) =>

              this.echeqSubmissionMedicalService.createSubmissionBatch(1, {

                  echeqFamilies: [

                      echeqFamily.family

                  ],

                  participants: [

                      patientId


                  ]

              }).pipe(

                  tap(result => console.log(reslult))

              )

          )

        )

      )

    ).subscribe(

      result => {

          this.dialog.close();

          this.snackBar.open('De vcheq(s) zijn verstuurd', 'Ok');

      },

      error => {

          console.error('Server error when assigning vcheq', error);

          this.snackBar.open('Er ging iets mis bij het opsturen, probeer het later nog een keer', 'Ok');

          this.dialog.close();

        }

    );

  }

}


查看完整回答
反對 回復 2022-01-13
  • 1 回答
  • 0 關注
  • 235 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號