SamuelSau / blitzboiggbackend

1 stars 0 forks source link

summonerData bug for retrieving other summoner's information #4

Closed SamuelSau closed 1 year ago

SamuelSau commented 1 year ago

Potential Unfixable Bug?

I've only tested using summonerName, DontThinkJustDo, for backend testing. However, using other summoner names led to undefined types for queueType, tier, rank, wins, losses.

For example: Happy

Accessing https://na1.api.riotgames.com/lol/league/v4/entries/by-summoner/${summonerIdResponse.data.id} where const summonerData = summmonerStatsResponse.data[0]; cannot access summonerData.queueType and etc.

Using applications such as op.gg or blitz.gg also were unable to retrieve these information.

I assume since the season restarted for League of Legends in preparation for Season 13 sometime in January, Riot API has reset these information. Furthermore, I believe that could be the case of a timer set in place when playing a certain gamemode such as ranked queue that expires after some time and resets, hence why DontThinkJustDo's information is still present.

SamuelSau commented 1 year ago

Creating axios error handler and setting default values for these information

SamuelSau commented 1 year ago

Upon investigation, I tried using Riot's provided API to test using the summonerName "Happy" and found that the second axios.get() request gave me a 200 response status, but gave me an empty array. Further testing the Riot's Matches endpoints, I was still able to successfully get the list of matchIds and get all the match details from the last two endpoints.

SamuelSau commented 1 year ago

Fixed bug.

The issue was solved by checking if summonerData was empty (or the length of the array === 0), then I set default values to queueType, tier, rank, wins, and losses. I also put safety measurements in the database for default values and ensured that they are not required for the future queries and requests.

summonerDataBugFix