Reputation: 608
The goal
I want to execute one http request and also want to do a other http request that is based on a if statement. The observer need to do a emit when:
This is some pseudo code that I have
class ApiCallClass {
methodThatReturnsObservable: Observable<{}> {
observable = this.http.get(firstUrl);
if (firstvar !== secondvar) {
observable.concat(this.http.get(secondUrl);
}
return observable;
}
}
Questions
We noticed that the second request is aborting. Is this something because of using concat and returning the observable?
Do I use the concat method correctly?
Upvotes: 0
Views: 72
Reputation: 691635
concat()
returns a new Observable. It doesn't mutate the original one.
So you need
observable = observable.concat(this.http.get(secondUrl);
Upvotes: 3