11export function getRandomGame ( ) {
22 const year = 2023 // Math.floor(Math.random() * 7 + 2015);
3- const url = `https://v1.basketball.api-sports.io/odds?league=12&season=${ year + "-" + ( year + 1 ) } `
3+ const url = `https://v1.basketball.api-sports.io/odds?league=12&season=${ year + "-" + ( year + 1 ) } `
44 return fetch ( url , {
55 method : "GET" ,
66 headers : {
7- "x-rapidapi-key" : "8097ad8b9eb665d99d8e442839cce0cc "
7+ "x-rapidapi-key" : "9f18683bd23d36897c490739f4780e16 "
88 }
99 } )
1010 . then ( ( response ) => response . json ( ) )
1111 . then ( ( json ) => {
1212 const response = json [ "response" ] ;
13- // console.log(response);
1413 const random = Math . floor ( Math . random ( ) * response . length ) ;
1514 const game = response [ random ] [ "game" ] ;
16- // console.log(game["teams"]["home"]["name"] + " vs " + game["teams"]["away"]["name"]);
17- return game [ "id" ]
15+ return game [ "id" ] ;
1816 } )
1917 . catch ( ( error ) => {
2018 throw `GET request to "${ url } " failed with error:\n${ error } `
@@ -33,7 +31,9 @@ export function getBets(gameId) {
3331 . then ( ( json ) => {
3432 console . log ( json ) ;
3533 const bookmakers = json [ "response" ] [ 0 ] [ "bookmakers" ] ;
36- for ( let i = 0 ; i < bookmakers . length ; i ++ ) {
34+
35+ for ( let i = 0 ; i < bookmakers . length ; i ++ ) {
36+
3737 if ( bookmakers [ i ] [ "name" ] === "Marathon Bet" ) {
3838 console . log ( "Found Marathon bet" )
3939 const bets = bookmakers [ i ] [ "bets" ] ;
@@ -42,14 +42,17 @@ export function getBets(gameId) {
4242 "Highest Scoring Quarter"
4343 ]
4444 let targetBets = { }
45- for ( let j = 0 ; j < bets . length ; j ++ ) {
45+
46+ for ( let j = 0 ; j < bets . length ; j ++ ) {
4647 if ( targetBetNames . includes ( bets [ j ] [ "name" ] ) ) {
4748 targetBets [ bets [ j ] [ "name" ] ] = bets [ j ] ;
4849 }
4950 }
50- return targetBets
51+
52+ return targetBets ;
5153 }
5254 }
53- return { }
55+
56+ return { } ;
5457 } )
5558}
0 commit comments