Retrieve the overall number of job openings from the Github Job API

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)
  //   })
  // }

}

Answer №1

After reviewing the documentation, it seems there isn't any mention of this specific issue. One potential solution could involve creating a loop to fetch all the JSON files and then merging them, although I would advise against making excessive API calls.

If you're interested in determining just the number of job positions available, you could implement a looping mechanism to request the list for each page until an error occurs. By incorporating a counter within the loop and multiplying the result by 50, you may arrive at a close approximation of the total quantity.

I stumbled upon additional insights from this source. The individual proposes that you can extract the URL for the final page directly from your initial query.

Alternatively, you could simply click on this link to reveal the overall number of job openings displayed prominently at the top of the page.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The Chrome browser's memory heap is reported to be a mere 10 MB, yet the task manager displays a whopping

When using Chrome's memory profiler, I notice that the heap size is always around 10 MB. However, the memory in my task manager keeps increasing and can reach over 1 GB if I leave my website running. Even though the heap size remains less than 10 MB w ...

Struggling with customizing the style of react mui-datatables version 4

Currently, I am utilizing "mui-datatables": "^4.2.2", "@mui/material": "^5.6.1", and have attempted to customize the styling in the following manner: Refer to the Customize Styling official documentation for more details // CUSTOMIZING MUI DATATABLES imp ...

Converting dates in Javascript

I have retrieved a date/time value of "20131218" from an API response. My goal is to transform this date into the format "2013-12-18". In PHP, this can be easily achieved with the following code: echo date("Y-m-d", strtotime('20131218')); The ...

I encounter difficulties using my static resources in the root route of my Express.js application

Can you guide me on how to implement styles and images from the assets folder in my webpage, specifically for the root route? As an example, I have a styles.css file located at assets/styles.css. In my code, I am using app.use(express.static('assets&a ...

Angular is expecting data of type string or number for the operands provided

When working in VS Code, I encountered the following warning: "Expected operands to be a string or number type" https://i.stack.imgur.com/lULLQ.png The contentType variable is defined as a string. I noticed that when I remove 'data:', every ...

Leveraging JavaScript code repeatedly

Apologies if this question has been asked before, as I couldn't find it. I have an HTML table with images used as buttons: <td> <button class="trigger"> <img src="D:\Elly Research\ CO2858\Presentation\Calypso ...

Is there a way to verify that my transition from angular 2 to angular 4 in my app was successful?

Previously, my .NET WebAPI application utilized angular 2, but I made the decision to transition to angular 4. To upgrade, I executed the following commands in the cmd within my project directory (in addition to addressing any missing dependencies): npm ...

Having trouble retrieving the recently updated data from the useReducer hook within a function defined in setTimeout

Within my application, I have encountered an issue while using a dispatch from the useReducer hook. Specifically, when I trigger a click event on a button that contains a setTimeout function of 2 seconds, the updated value is not reflected in the setTimeou ...

How can I pass an Objective-C object to JavaScript?

Currently, I am working on a UIWebView project that involves HTML and JavaScript. One of my friends is working on something similar but for Android. The challenge I'm facing is that in Android, there is a simple way to send an Android object to JavaS ...

Modify the values of an object by utilizing the setter function

How can I utilize the setter method to update existing values of an object and perform mathematical operations? var obj = { set model(object) { //method's logic } }; obj = {x:10, y: 20, p: 15}; obj = { x:10, y: 20, p: 15 set mod ...

Inserting a pause between a trio of separate phrases

I am dealing with three string variables that are stacked on top of each other without any spacing. Is there a way to add something similar to a tag in the ts file instead of the template? Alternatively, can I input multiple values into my angular compo ...

Creating a list of font sizes for each <p> tag in my HTML document

I am looking to create an array containing the font sizes of all the p tags in my HTML document. How can I specifically target only the p elements and not their parent elements? ...

Preparing an Angular 2 application for deployment on a live IIS server

After following the Angular 2 tutorial successfully and getting everything to work as expected, I realized that it doesn't cover packaging for production distribution. Is there a standard method for creating a clean distribution package without includ ...

Storing browser cookies in Azure Static Web App

I recently set up a solution on Azure with a web API in .NET 6 deployed to App Service, and a front-end application in Angular deployed to Azure Static Web App. I made sure to configure CORS on the back-end App Service to allow the front-end origin. Howeve ...

Conditionally Add Columns to jQuery Datatables

I am working with a jQuery datatable to showcase data retrieved through an AJAX request. However, I am interested in adding a third column to the table specifically for administrators, allowing them to delete entries. Can someone guide me on how to incorpo ...

Methods to modify the state of a Modal component beyond the boundaries of a React class

I am attempting to trigger my modal by modifying the state from outside of the react class. Unfortunately, I have had no success thus far. I have experimented with the following approach: In my code, I have a method named "Portfolio" that is responsible f ...

Understanding the contrast between a put request subscription with an arrow versus without in Typescript

I'm sorry if the title is not very clear. In my Angular project, I have come across two different put requests: public Save() { const types: string[] = this.getTypes.getCurrentTypes(); this.userTypeService .updateTypes(this.userID, gro ...

What is the recommended return type in Typescript for a component that returns a Material-UI TableContainer?

My component is generating a Material-UI Table wrapped inside a TableContainer const DataReleaseChart = (): React.FC<?> => { return ( <TableContainer sx={{ display: 'grid', rowGap: 7, }} > ...

Encountering a 403 error with RXJS when attempting to subscribe to a websocket in Angular

I am currently searching for a resolution to this issue without making any upgrades to Angular or its dependencies, as it could potentially impact other parts of the code base package.json { "name": "angular4", "version": "1.0.0", "description" ...

The error message "Property not found on type 'Product | Customer' in React Typescript" is indicating that the specified property does not exist on the

I am currently working on a React app using TypeScript where I need to manage data for Customers and Products. To enhance this functionality, I plan to create a form component that can be used for updating either a Customer or a Product. The idea is to pr ...