¡Soy un principiante en js! ¿Hay alguna forma de dejar que el retorno espere a que terminen ambos bucles? Probé todas las soluciones aquí " https://stackoverflow.com/questions/27914209/how-could-i-run-a-function-after-the- complete-of-a-for-loop-in-node-js", pero ninguno de ellos funciona, creo porque es un bucle anidado, incluso este . ¿Cómo podría ejecutar una función después de completar un bucle for en Node.js?
function StatisticsPerGameId (IDs){ console.log(IDs) let doubldoubl={}; for (let i=0; i <IDs.length;i++){ const options = { method: 'GET', url: 'https://api-nba-v1.p.rapidapi.com/players/statistics', params: {game: IDs[i]}, headers: { 'X-RapidAPI-Host': 'api-nba-v1.p.rapidapi.com', 'X-RapidAPI-Key': 'afgsdgbsdghbrynhndf6hn6dfhndfhn61dhddfhn' } }; axios.request(options).then(function (response) { console.log(response.data.response[0].points) for(let j in response.data.response){ let dd = 0; if( response.data.response[j].points >= 10){dd=dd+1;}; if( response.data.response[j].totReb >= 10){dd=dd+1;}; if(dd == 2 ){ doubldoubl=doubldoubl+{ name:response.data.response[j].player.firstname +" "+ response.data.response[j].player.lastname, teamOfplayer : response.data.response[j].team.name, teamOfplayerlogo:response.data.response[j].team.logo, } }; dd = 0 ; } }).catch(function (error) { console.error(error); }); } return doubldoubl; }