So i'm trying to use the https://americas.api.riotgames.com/lol/match/v5/matches/ get function and read values from the results. I can read it fine, but when I go to reference a field from it, i get this undefined issue, (https://i.stack.imgur.com/7DIyo.png). When I try to do JSON.parse to it, I get this:(https://i.stack.imgur.com/DOjok.png) even though when I copy and paste the json to json lint, it validates it all fine.
At this point I've tried every possible naming convention, validating the JSON, I've tried converting it to string to remove white spaces. Honestly I'm just a bit stumped as the other Riot API calls I've used have been working completely fine with no issue (match/v5/matches/by-puuid/ and summoner/v4/summoners/by-name/). Here is the code:
function getMatch(matchId,puId){
const https = require('node:https');
https.get('https://americas.api.riotgames.com/lol/match/v5/matches/'+matchId+'?api_key='+riotApiKey, (resp) => {
resp.on('data', (d) => {
process.stdout.write(d.info.gameDuration);
let matchResults = JSON.parse(d);
});
});
}
Here is the response i get: https://pastebin.com/0f7waaAJ