I have a script that works locally but does not work once I put it on Lambda.
There are two functions: playerStatsForAllGamesForPreviousDay
and previousDaysGames
.
...
const previousDaysGames = async () => {
const full_games = await axios(
{
method: 'get',
url: `https://api-nba-v1.p.rapidapi.com/games/date/${oneDayBefore}`,
headers: {
'x-rapidapi-host': 'api-nba-v1.p.rapidapi.com',
"x-rapidapi-key": 'XXXXXXX'
}
}
).then((res)=>res.data.api.games.map(game=>game.gameId)).catch(err=>console.log('ERROR',err))
return full_games
}
....
const playerStatsForAllGamesForPreviousDay = async () => {
console.log('playerStatsForAllGamesForPreviousDay')
let gameIds = await previousDaysGames()
console.log(gameIds)
let promises = []
gameIds.map( async (v)=> {
promises.push(playerStatsForSpecificGameForPreviousDay(v))
})
return Promise.all(promises)
.then((results) => {
const flattenedResults = [].concat.apply([], results)
return flattenedResults
})
.catch((errors) => {
console.log(errors)
})
}
...
There is more to the script then these two functions, but the script runs until playerStatsForAllGamesForPreviousDay
calls previousDaysGames
; once this happens, the script doesn't go past this point specifically, it doesn't go past const full_games = await axios
; I can tell it doesn't go past this point, because I've put console.logs and deployed to Lambda and looked at the CloudWatch logs.
There is nothing that is returned for an error from the logs, which makes this difficult, and I'm interested in finding out more ways to debug and if anyone has an idea of a solution.