I have this app that makes call to API and extracts gameIDs from returned object.
/* jshint ignore:start */
        axios
          .get(
            `https://api.mysportsfeeds.com/v1.2/pull/nba/${seasonName}/scoreboard.json?fordate=${
              date.yesterday
            }`,
            config
          )
          .then(response => {
            this.sports_feeds_data = response.data.scoreboard.gameScore;
            return this.sports_feeds_data;
          })
          .then(response => {
            // Fill up array with all the game ID's for today's games
            // This will be used to retrieve the Box Scores later
            response.forEach(function(item, index) {
              gameIDs[index] = item.game.ID;
            });
            return gameIDs;
          })
          // Now call getBoxScores to retrieve box scores
          .then(gameIDs => {
            test = getBoxScores(gameIDs); // **No value returned**
            console.log(test);
          })
          .catch(error => {
            console.log(error);
            this.errored = true;
          });
        /* jshint ignore:end */
Now we go into getBoxScores and get boxScores:
let boxScores = [];
let promises = [];
/* jshint ignore:start */
const getBoxScores = gameIDs => {
  gameIDs.forEach(function(item) {
    let myUrl = `https://api.mysportsfeeds.com/v1.2/pull/nba/2018-2019-regular/game_boxscore.json?gameid=${item}`;
    promises.push(
      axios({
        method: "get",
        headers: {
          Authorization:
            "Basic NzAxMzNkMmEtNzVmMi00MjdiLWI5ZDYtOTgyZTFhOnNwb3J0c2ZlZWRzMjAxOA=="
        },
        url: myUrl,
        params: {
          teamstats: "none",
          playerstats: "PTS,AST,REB,3PM",
          sort: "stats.PTS.D",
          limit: 3,
          force: true
        }
      })
    );
  });
  axios
    .all(promises)
    .then(function(results) {
      results.forEach(function(response) {
        boxScores.push(response.data.gameboxscore);
      });
      return boxScores;
    })
    .then(function(boxScores) {
      console.log(boxScores);
      return boxScores;
    });
};
/* jshint ignore:end */
module.exports = getBoxScores;
Problem: 1. Unable to return boxScores array from to getBoxScores.js.
- When I console.log test I get nothing in array. console logging boxScores I see my resolved promises with values. Any insight appreciated. Thanks...
Updated resolution:
.then(async gameIDs => {
        // Check if boxscores have been retrieved on previous tab click
        this.sports_feeds_boxscores.nba =
          this.sports_feeds_boxscores.nba || (await getBoxScores(gameIDs));
      })
And in getBoxScores:
// axios.all returns a single Promise that resolves when all of the promises passed
// as an iterable have resolved. This single promise, when resolved, is passed to the
// "then" and into the "values" parameter.
await axios.all(promises).then(function(values) {
  boxScores = values;
});
return boxScores;
};
    module.exports = getBoxScores;
The above update now works...
