1

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.

4
  • does this help? stackoverflow.com/questions/28449363/… Commented Feb 22, 2020 at 7:03
  • 1
    it put me in a direction that I wasn't thinking about that ultimately solved the issue. it was a very useful clue, and I appreciate it Commented Mar 8, 2020 at 3:54
  • @schoenbl how do you resolve this issue? Can you guide us? Commented Oct 19, 2022 at 6:45
  • @Dipak sorry, but i don't remember. message me directly if you'd like. i'm guessing you found some type of solution by now. did you check the node version on lambda and make sure there wasn't a timeout issue? Commented Nov 10, 2022 at 6:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.