Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. function accountSummary(userid){
  2. var xhr = new XMLHttpRequest();
  3. xhr.open("GET", "https://www.bungie.net/platform/Destiny/Stats/Account/2/" + userid + "/", true);
  4. xhr.setRequestHeader("X-API-Key", apiKey);
  5.  
  6. xhr.onreadystatechange = function(){
  7. if(this.readyState === 4 && this.status === 200){
  8. var json = JSON.parse(this.responseText);
  9. //document.writeln(this.responseText);
  10. //document.writeln(json.Response.data.characters.length);
  11.  
  12.  
  13. for (var index = 0; index < 3; index++){
  14. // This line gives you a temporary variable that contains the current character you're looking at, which makes subsequent code more readable
  15. var currentCharacter = json.Response.data.characters[index];
  16. // Do something that uses currentCharacter.baseCharacter.minutesPlayedTotal, or whatever other properties on currentCharacter that you want!
  17. document.writeln(currentCharacter.baseCharacter.minutesPlayedTotal);
  18. }
  19. }
  20. }
  21.  
  22. xhr.send();
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement