-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (29 loc) · 963 Bytes
/
index.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
import fetch from 'node-fetch';
var allData, teams, elements;
function setVar(value) {
allData = value;
teams = allData.teams;
elements = allData.elements;
listAllPlayersForTeam("TEAM_NAME");
}
function listAllPlayersForTeam(teamName) {
var teamCode = -1;
for (var i in teams) {
var parent = teams[i].name.toString().toLowerCase();
var child = teamName.toLowerCase();
if (parent.includes(child)) {
teamCode = teams[i].code;
break;
}
}
if (teamCode == -1) console.log("No teams with this name");
else {
for (var j in elements) {
if (elements[j].team_code == teamCode) console.log(elements[j].first_name + " " + elements[j].second_name);
}
}
}
var response = fetch('https://fantasy.premierleague.com/api/bootstrap-static/')
.then(res => res.json())
.then(res => setVar(res));
// Team Name, Position, Statistic with a Threshold