Reputation: 25
I have an API that I want to read certain data from, it works for most of the data but not for one. Namely, the part that I show below, I have to navigate to the "mmr" and there it fails from the number, the season. Maybe someone can help me, I have here the program code and the part which gets the API, in addition I link the API once. Thanks in advance! https://www.npmjs.com/package/r6api.js/v/1.6.0#typescript-integrations-1
const id = await r6api.getId(platform, username).then(el => el[0].userId);
const rank = await r6api.getRank(platform, id, { regions: ['euw'] }).then(el => el[0]);
console.log(`${username} has ${rank.seasons.number['-1'].id} mmr.`);
And the result of the API for the getRank
[
{
id: '0b95544b-0228-49a7-b338-6d15cfbc3d6a',
seasons: {
'16': {
id: 16,
name: 'Shifting Tides',
regions: {
emea: {
region: 'emea',
skillMean: 30.663307433,
skillStdev: 7.5624420961,
current: {
name: 'Unranked',
id: 0,
mmr: 3066,
image: 'https://i.imgur.com/bvnVUEm.png'
},
max: {
name: 'Unranked',
id: 0,
mmr: 0,
image: 'https://i.imgur.com/bvnVUEm.png'
},
lastMatch: { mmrChange: 0, won: false, skillStdevChange: -0.0048172252 },
previousMmr: 0,
nextMmr: 0,
topRankPosition: 0,
kills: 0,
deaths: 0,
wins: 0,
losses: 0,
matches: 0,
abandons: 0,
updateTime: '1970-01-01T00:00:00+00:00'
}
}
}
}
}
]
Upvotes: 0
Views: 117
Reputation: 49
If its the MMR alone you want I made this ridiculous method that works, it currently just returns the MMR but you can sort of figure it out:
const id = await r6api.getId("uplay", "username").then(el => el[0].userId);
const rank = await r6api.getRank("uplay", id, { regions: ['euw'] }).then(el => el[0]);
const info = Object.values(Object.values(Object.values((Object.values(rank))[1])[0])[4])[0]
console.log(info.max.mmr)
Upvotes: 1