forked from Patrick-FRE/json-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
83 lines (79 loc) · 2.08 KB
/
index.html
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Event List</title>
</head>
<body>
<table>
<tr>
<th>Event name</th>
<th>Start date</th>
<th>End date</th>
<th>Actions</th>
</tr>
<tr>
<td>
<input disabled value="TEST-3" />
</td>
<td>
<input type="date" value="2020-01-08" />
</td>
<td>
<input disabled />
</td>
<td>
<button>EDIT</button>
<button>DELETE</button>
</td>
</tr>
</table>
<script>
// Get all Events
fetch("http://localhost:3000/events")
.then((response) => response.json())
.then((json) => console.log(json));
// Create a new Event
fetch("http://localhost:3000/events", {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({
eventName: "TEST",
startDate: "1641790800000",
endDate: "1641790800000",
}),
})
.then((response) => response.json())
.then((json) => console.log(json));
// Delete an exist Event
fetch("http://localhost:3000/events/1", {
method: "DELETE",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
})
.then((response) => response.json())
.then((json) => console.log(json));
// // Update an exist Event
fetch("http://localhost:3000/events/2", {
method: "PUT",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({
eventName: "TEST-CHANGED",
startDate: "1641790800000",
endDate: "1641790800000",
}),
})
.then((response) => response.json())
.then((json) => console.log(json));
</script>
</body>
</html>