Skip to content

Second call to league.Match.gettingById invisbly fails #20

@bencooper222

Description

@bencooper222

I'm writing a basic tool to grab a list of matches from the past 24 hours and just console.log them right now. I'm successfully getting the matchlist with the encrypted summoner ID. Then, I'm getting the detailed data by getting with the matchID. I'm trying to do this for the entire matchlist but it only works for the first one in the matchlist. Running through a debugger, it appears that the code just mysteriously (and without an error) crashes at MatchEndpoint.js:48.

I'm sure that getting a summoner's list of matches and the details about them is a fairly solved challenge so I'm guessing this issue doesn't actually require a fix. That said, it seems like something wonky is going on with my use of your library - not my use of Promises and async/await more broadly.

My project is will be open so I have the luxury of sharing my code with you:

const league = new (require('leaguejs'))(process.env.LEAGUE_KEY);
const { season, queue } = require('./constants');

exports.getSummonerDataSince = async beginTime => {
  const matchList = (await league.Match.gettingListByAccount(
    process.env.LEAGUE_ACCOUNT_ID,
    process.env.LEAGUE_API_PLATFORM_ID,
    { beginTime },
  )).matches;

  const data = [];

  for (let match of matchList) data.push(await getGameData(match.gameId));

  return data;
};

const getGameData = async matchId => {
  console.log('start fetch');
  const fullData = await league.Match.gettingById(matchId);
  console.log('data fetched');
  return {
    season: season(fullData.seasonId),
    queue: queue(fullData.queueId),
    duration: fullData.gameDuration,
  };
};

// this code only printed out "start fetch", "data fetched", "start fetch"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions