Closed travisryan closed 5 years ago
Ok I've been trying to debug your code, and learning alot in the process...
It appears that on the second call ( the variable "schedule" is fine, but once it is run through the filter, it is blank. Also the matchupPeriodId is ok, so not sure why it's failing to filter properly....
getBoxscoreForWeek({ seasonId, matchupPeriodId, scoringPeriodId }) {
const routeBase = ${seasonId}/segments/0/leagues/${this.leagueId}
;
const routeParams = ?view=mMatchup&view=mMatchupScore&scoringPeriodId=${scoringPeriodId}
;
const route = ${routeBase}${routeParams}
;
return axios.get(route, this._buildAxiosConfig()).then((response) => {
const schedule = _.get(response.data, 'schedule');
const data = _.filter(schedule, { matchupPeriodId });
console.log("In Client..BoxscoreForWeek="+matchupPeriodId);
console.log({matchupPeriodId});
console.log(data);
return _.map(data, (matchup) => (
Boxscore.buildFromServer(matchup, { leagueId: this.leagueId, seasonId })
));
});
I'm a moron. If the value of matchupPeriodId is passed as a string value and not a number, it breaks everything like above. ;)
I'm using Ionic and Angular, etc. I have a dropdown for Week number. When I change the week number and call the same code for BoxScores, the boxscores.length is 0. It works the first page load, but then won't work on reloads. If I hardcode the week to any week number, it will load correctly the first time.
Also I know your code is getting the right data the second time on my update as the Network tab in chrome dev tools shows that it returned the right data. I'm assuming something has gone wrong in the getBoxscoresForWeek function on subsequent calls.
Help anyone?