Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function accountSummary(userid){
- var xhr = new XMLHttpRequest();
- xhr.open("GET", "https://www.bungie.net/platform/Destiny/Stats/Account/2/" + userid + "/", true);
- xhr.setRequestHeader("X-API-Key", apiKey);
- xhr.onreadystatechange = function(){
- if(this.readyState === 4 && this.status === 200){
- var json = JSON.parse(this.responseText);
- //document.writeln(this.responseText);
- //document.writeln(json.Response.data.characters.length);
- for (var index = 0; index < 3; index++){
- // This line gives you a temporary variable that contains the current character you're looking at, which makes subsequent code more readable
- var currentCharacter = json.Response.data.characters[index];
- // Do something that uses currentCharacter.baseCharacter.minutesPlayedTotal, or whatever other properties on currentCharacter that you want!
- document.writeln(currentCharacter.baseCharacter.minutesPlayedTotal);
- }
- }
- }
- xhr.send();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement