'How do I filter and then use API Data?

I have this sports API and I want to be able to pull only certain league ids from this data and use those selected leagues to display them.

here is the API Call code:

const settings = {
"async": true,
"crossDomain": true,
"url": "https://v3.football.api-sports.io/fixtures?date=2021-04-07",
"method": "GET",
"headers": {
    "X-RapidAPI-Host": "v3.football.api-sports.io",
    "X-RapidAPI-Key": "MY-API-KEY"
}

};

the format of the API data is as follows:

League ID is the ID that identifies each game (there are 307 games in the picture). I have a list of League IDs (I assume I make an array with them) that I want to keep and I want to get rid of the rest of the League IDs from the data

After this I want to display the information of the League IDs that I have kept from the data.

Edit: Andrew asked for what I have so far

$.ajax(settings).done(function (response) {
console.log(response);
for(let i=0; i<response.length; i++) {
    console.log(i)
    if (response.i.league.id=40) {
    console.log("boom")
    }
}

});

I assumed looping through it somehow was the best way, perhaps using foreach()?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source