【发布时间】:2019-07-03 10:52:40
【问题描述】:
我已经多次看到这个问题,但我不知道如何实施它来解决我的问题。
我基本上有一组需要按顺序执行的 http 调用。具体来说,我需要执行一个,等待它返回然后执行下一个。
let requests = [
this.http.post('http://localhost:4200/api/value', 'one'),
this.http.post('http://localhost:4200/api/value', 'two'),
this.http.post('http://localhost:4200/api/value', 'three'),
this.http.post('http://localhost:4200/api/value', 'four'),
];
所以我目前正在使用 forkJoin 但这不是我想要的同时运行请求。
forkJoin(observableBatch).subscribe(result => {
// success
}, error => {
// log error
});
我使用concatMap 阅读可能是答案,但我如何在可观察的数组上使用它?
【问题讨论】: