(An Angular app)
Im fetching data from https://jobs.github.com/positions while looping their pages, because each page contains 50 available positions, and I want to get the positions from all of their pages.
Service.ts:
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class PositionserviceService {
// uri = 'https://jobs.github.com/positions'
constructor(public http: HttpClient) { }
getAllPositions(){
return this.http.get('https://cors-anywhere.herokuapp.com/https://jobs.github.com/positions.json');
}
getAllPoistions2(page){
return this.http.get(`https://cors-anywhere.herokuapp.com/https://jobs.github.com/positions.json?page=${page}`);
}
}
Component.ts:
getAllPositions(){
for(let i = 1; i<=5; i++){
this.positions.push(this.positionService.getAllPoistions2(i))
}
console.log("This positions:",this.positions)
forkJoin(this.positions).subscribe((data:Object[]) => {
this.allPositions = data
console.log("All Positions:", this.allPositions)
})
}
The response is:
So my question is: how do I merge these 5 arrays into one array?
Much appreciated!