I would like to do a multi call using 'HttpClient'. Something similar that I used to use with axios.
Using axios with Vue:
return axios.all([
axios.get('/friends/name'),
axios.get('/family/name'),
axios.get('/collegue/name'),
])
Trying with angular:
return this.http.all([
this.http.get('/friends/name'),
this.http.get('/family/name'),
this.http.get('/collegue/name'),
])
error TS2339: Property 'all' does not exist on type 'HttpClient'
Try with forkJoin like this:
ngOnInit() {
const request1 = this.http.get('/friends/name');
const request2 = this.http.get('/family/name');
const request3 = this.http.get('/collegue/name');
forkJoin([request1, request2, request3]).subscribe(data => {
this.response1 = data[0];
this.response2 = data[1];
this.response3 = data[2];
});
}