I used concat to chain two API calls, the second call uses the response of the first call.
The problem is that when I try to console.log() the response of the First Call I get undefined. and it says in the console that the first call is being made before the second call.
dataFromFirstCall: any
constructor(private http: HttpClient) {
concat(
this.firstCall(),
this.secondCall(this.dataFromFirstCall)
).subscribe()
}
getResponse() {
return this.http.get('assets/dummyData.json').pipe(tap(data => {
console.log('First call')
this.dataFromFirstCall=data;
})
)
}
secondCall(response: any) {
console.log(response, 'Second call')
return this.http.get('assets/dummyData2.json')
}
