I have successfully created an Angular application that mirrors the functionality of
However, I encountered a limitation where only 50 positions are available per page,
To fetch additional jobs beyond the initial 50, I need to append "?page=X" to another GET request.
As a result, my GET response currently only retrieves the first page of positions.
Is there a way to retrieve the total number of positions using just one GET request or through alternative methods?
Any suggestions or guidance would be greatly appreciated!
Here is my code:
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');
}
getNextPage4(page){
return this.http.get(`https://cors-anywhere.herokuapp.com/https://jobs.github.com/positions.json?page=${page}`);
}
}
Componnent.ts file:
import { Component, OnInit } from '@angular/core';
import { PositionserviceService } from '../services/positionservice.service';
@Component({
selector: 'app-showallpositions',
templateUrl: './showallpositions.component.html',
styleUrls: ['./showallpositions.component.css']
})
export class ShowallpositionsComponent implements OnInit {
positions: Object
positions4: Object
isCollapsed = true;
constructor(public positionService: PositionserviceService) { }
ngOnInit() {
this.positionService.getAllPositions().subscribe(data => {
this.positions = data;
console.log(this.positions)
})
// this.getPage4()
}
// getPage4(){
// this.positionService.getNextPage4().subscribe(data4 => {
// this.positions4 = data4;
// console.log("Page 4:", this.positions4)
// })
// }
}