From af026aa3a71e543f1efd7a03e34ac93c92704fd9 Mon Sep 17 00:00:00 2001 From: Conrad Date: Fri, 10 Jan 2020 09:55:41 +0100 Subject: [PATCH] Fixed a bug with the GitHub history --- src/pages/history.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/pages/history.js b/src/pages/history.js index a43f55e..32d1aa3 100644 --- a/src/pages/history.js +++ b/src/pages/history.js @@ -29,20 +29,23 @@ function addGitHistory(data) { " (Link)" - document.getElementById("log").appendChild(new_li) + var log = document.getElementById("log") + log.appendChild(new_li) } } } // Send HTTP request to the GitHub API to get information about this repo -const Http = new XMLHttpRequest() -Http.open("GET", GIT_URL) -Http.send() +function getGitHubAPIData() { + const Http = new XMLHttpRequest() + Http.open("GET", GIT_URL) + Http.send() -// If the API responds call the addGitHistory function -Http.onreadystatechange = function() { - if (this.readyState === 4 && this.status === 200) { - addGitHistory(JSON.parse(Http.responseText)) + // If the API responds call the addGitHistory function + Http.onreadystatechange = function() { + if (this.readyState === 4 && this.status === 200) { + addGitHistory(JSON.parse(Http.responseText)) + } } }