我有一个角度应用程序,我正在通过服务调用进行发布请求。
但我得到一个错误。但是服务调用会发送请求。所以这是一个非常具有误导性的错误。
这是我的方法:
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
at subscribeToResult (subscribeToResult.js:11)
at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._innerSub (mergeMap.js:74)
at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._tryNext (mergeMap.js:68)
当然,我首先搜索了这个错误。但我只发现与其他东西相关的andswares,比如这个answare:
TypeError:您在预期流的位置提供了无效对象。您可以提供 Observable、Promise、Array 或 Iterable