-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhighscores.js
59 lines (36 loc) · 1.17 KB
/
highscores.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function makeList() {
var listContainername = document.getElementById('listHighscorename');
var listContainerscore = document.getElementById('listHighscorescore');
var numberOfListItems = dataHighscore.length;
var listItem;
var listItemscore;
var i;
for (i = 0; i < numberOfListItems; ++i) {
listItem = document.createElement('li');
listItemscore = document.createElement('li');
listItemscore.setAttribute("id", "listscore");
listItem.setAttribute("id", "listElem");
listItemscore.innerHTML = (dataHighscore[i].score);
listItem.innerHTML = (dataHighscore[i].userName);
listContainername.appendChild(listItem);
listContainerscore.appendChild(listItemscore);
}
}
var dataHighscore = [];
const option ={
method: 'get',
headers: {
'Content-Type': 'application/json'
}
};
fetch('/SVtoCLI', option)
.then(response => {
if(response.ok) {
return response.json();
}
}).then(data => {
dataHighscore = data;
makeList();
console.log(dataHighscore);
}).catch(err => console.error(err));
console.log(dataHighscore + "asdasasd");