var historyJson = {}; const maxIterations = 200; function getHistoryData(){ $.getJSON(host + '/api/event/' + clientUUID, function(data){ historyJson = data; displayHistory(); }); } function historyToHtml(){ var innerHTML = ''; var iterations = historyJson.length <= maxIterations ? historyJson.length : maxIterations; for(let i=0; i' + '' + parseTimeStamp(historyJson[i].dateTimeStamp) + '' + '' + historyJson[i].httpMethod + '' + '' + parseRequestBody(historyJson[i].requestBody, i) + '' + ' ' + ''; } return innerHTML; } function parseRequestBody(requestBody,i){ return requestBody.length == 0 ? "No request body" : '' } function parseTimeStamp(timeStamp){ return timeStamp.substring(0,19).replace('T',' '); } function parseHeaders(pos){ parsedJson = new Map(); headers = historyJson[pos].headers Object.keys( headers ).forEach( (jsonKey) => { parsedJson.set( jsonKey , headers[jsonKey] ); } ) return parsedJson; } function displayHistory(){ $('#historyTable tbody').html(historyToHtml()); }