Если ваши звонки нужно делать один за другим, вы можете связать их в очередь с помощью flatMap
:
getfirstCount() {
return this.http.post('ulr1',request,{headers:headers}) // <-- you have to returne an observable
.subscribe(response => {
dataCount1 = response.count
},
error => {
console.log(error);
},
() => {
this.getSecondCount();
}
)
}
и использовать его следующим образом:
getfirstCount()
.flatMap((dataFirstCount) => getSecondCount(dataFirstCount))
.flatMap(...)
.subscribe(/* handle dataFourthCount */)