I am pulling data from an API that looks like this:
[{
id: "62ff4289163f2d1ec1d54ff16bd8d731",
sport_key: "americanfootball_ncaaf",
commence_time: "2021-08-28T17:00:00Z",
home_team: "Illinois Fighting Illini",
away_team: "Nebraska Cornhuskers",
bookmakers: [{
key: "unibet",
title: "Unibet",
last_update: "2021-07-16T23:33:36Z",
markets: [{
key: "spreads",
outcomes: [{
name: "Illinois Fighting Illini",
price: 1.89,
point: 8
},
{
name: "Nebraska Cornhuskers",
price: 1.89,
point: -8
}
]
}]
},
{
key: "barstool",
title: "Barstool Sportsbook",
last_update: "2021-07-16T23:28:36Z",
markets: [{
key: "spreads",
outcomes: [{
name: "Illinois Fighting Illini",
price: 1.91,
point: 8
},
{
name: "Nebraska Cornhuskers",
price: 1.91,
point: -8
}
]
}]
}
]
The relevant section of my code looks like this (the (data) is the JSON posted above):
response.on("end", () => {
const oddsData = JSON.parse(data);
let games = oddsData.length;
for(let i=0; i<games; i++){
let bookies = oddsData[i].bookmakers.length;
for(let b=0; b<bookies; b++){
console.log(oddsData[i].bookmakers[b]);
}
}
})
How can I filter to only show results for the bookmaker with the key "barstool"? I have been googling different array filters and reduce functions all week and I cannot get this figured out. Any help is appreciated.