I have a service and its getAllMessages() returns an observable of an array of items : Observable<ITEM[]>
I map the result like this to post each ITEM to a RestAPI :
this.service.getAllMessages()
.map(items => ...for each item of items, call this.apiService.postMessage(item)...)
postMessage(item) returns an Observable<Response>
My goal is to get an Observable<Response[]> for which I can check the http code of every post from this.apiService.postMessage(item)
I tried using flatMap :
this.service.getAllMessages()
.flatMap(items => {
return items.map(item => {
return this.apiService.postMessage(item);
});
}).subscribe(RES => {
console.log(RES);
});
but here RES is an Observable<Response> and not a simple Response
How can I achieve this ?