-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequest.js
More file actions
51 lines (44 loc) · 1.16 KB
/
request.js
File metadata and controls
51 lines (44 loc) · 1.16 KB
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
class Request {
getGroups(value, success) {
fetch("http://localhost:3000/groups")
.then((response) => {
if (!response.ok) {
throw new Error("Ağ hatası: " + response.statusText);
}
return response.json();
})
.then((data) => {
console.log(data);
let groupName = data.find((group) => (group.Groupname === value));
success(groupName);
})
.catch((error) => {
console.error("JSON verisi çekme hatası:", error);
});
}
getMatches(team,fonk){
team = team.toLowerCase();
fetch("http://localhost:3000/rounds")
.then((response) => {
if (!response.ok) {
throw new Error("Ağ hatası: " + response.statusText);
}
return response.json();
})
.then((data)=>{
console.log(data);
data.forEach(element => {
let isMatch = false;
element.matches.forEach(matchs=>{
if (team == matchs.team1.name.toLowerCase() || team == matchs.team2.name.toLowerCase()) {
isMatch = true;
fonk(matchs);
}
});
// if(!isMatch){
// alert("Takım bulunamadı.")
// }
});
})
}
}