mkreiser/ESPN-Fantasy-Football-API

getTeamsByWeek being called twice?

travisryan opened this issue · 0 comments

I'm trying to figure out/debug what's going on inside your code and this is weird. I'm seeing a debug statement twice and I'm hoping I'm incorrect on what's going on here.

getTeamsAtWeek({ seasonId, scoringPeriodId }) {
    const routeBase = `${seasonId}/segments/0/leagues/${this.leagueId}`;
    const routeParams = `?scoringPeriodId=${scoringPeriodId}&view=mRoster&view=mTeam`;
    const route = `${routeBase}${routeParams}`;

    return axios.get(route, this._buildAxiosConfig()).then((response) => {
      const data = _.get(response.data, 'teams');
      console.log("In Client..");
      console.log(data);
      return _.map(data, (team) => (
        Team.buildFromServer(team, { leagueId: this.leagueId, seasonId })
      ));
    });
  }

I put the console.logs in by In Client, etc. and here is what I'm seeing in my console...
https://imgur.com/a/oMVQoa2

My code I'm calling looks like this..

await MyClientNorth.getTeamsAtWeek({ seasonId: this.seasonId, scoringPeriodId: this.scoringPeriodId }).then(async (teams) => {
      console.log(teams);
      
      await MyClientNorth.getBoxscoreForWeek({ seasonId: this.seasonId, scoringPeriodId: this.scoringPeriodId, 
        matchupPeriodId: this.matchupPeriodId }).then((boxscores) => {
          console.log("response received."+ boxscores.length);

....................

So what is going on? Why is In Client written out twice?