I am trying to get the response from the API call to output so that it is formatted with line breaks and so on. I tried both parse and stringify and still only get the output as a single line.
var HttpClient = function() {
this.get = function(url, callback) {
var anHttpRequest = new XMLHttpRequest();
anHttpRequest.onreadystatechange = function() {
if (anHttpRequest.readyState == 4 && anHttpRequest.status == 200)
callback(anHttpRequest.responseText);
}
anHttpRequest.open( "GET", url, true );
anHttpRequest.send( null );
}
}
var client = new HttpClient();
client.get("https://api.opendota.com/api/players/26202535/matches?limit=1",
function(response) {
JSON.parse(response);
console.log(response);
document.getElementById("demo").innerHTML=response;
});
Output: [{"match_id":3469695808,"player_slot":3,"radiant_win":true,"duration":1237,"game_mode":22,"lobby_type":7,"hero_id":13,"start_time":1506540251,"version":20,"kills":11,"deaths":2,"assists":12,"skill":3,"leaver_status":0,"party_size":1}]