-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathload.js
30 lines (22 loc) · 848 Bytes
/
load.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
let gameList = ['Pac-man', 'Donkey Kong', 'Super Mario', 'Paperboy']
let gamerList = ['LiekGeek', 'LX360', 'Observer']
let url = 'http://localhost:4972/api/v1.0/Scores/'
let getUrl = 'http://localhost:5618/'
setInterval(() => {
let gamer = gamerList[Math.floor(Math.random() * gamerList.length)];
let game = gameList[Math.floor(Math.random() * gameList.length)];
let score = Math.floor(Math.random() * 100);
fetch(`${url}${gamer}/${game}`, {
method: 'POST',
headers: {
"Content-Type": "application/json"
},
body: score
}).then((response) => {
console.log(`Added score {${score}} for gamer {${gamer}} on game {${game}}`);
})
}, 5000);
setInterval(() => {
let limit = Math.floor((Math.random() * 11) -1 );
fetch(`${getUrl}?limit=${limit}`)
}, 2000);