This repository has been archived by the owner on May 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservertest.js
executable file
·116 lines (96 loc) · 2.66 KB
/
servertest.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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
var http = require('http');
var postOptions = {
host: 'localhost',
port: '8080',
path: '/api/events',
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
};
var postRequest = http.request(postOptions, function(response) {
response.setEncoding('utf8');
response.on('data', function (chunk) {
console.log('Response: ' + chunk);
});
});
// post the data
var data = {"name":"HSR-Party","description":"Party an der HSR","targetGroup":"Studenten","contributionsDescription":"Kuchen","location":{"name":"hsr","street":"Oberseestrasse","zipCode":8640,"city":"Rapperswil"}};
postRequest.write(JSON.stringify(data));
postRequest.end();
var postOptions = {
host: 'localhost',
port: '8080',
path: '/api/events/2/guests',
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
};
var postRequest = http.request(postOptions, function(response) {
response.setEncoding('utf8');
response.on('data', function (chunk) {
console.log('Response: ' + chunk);
});
});
// post the data
var guest = {"name":"Bob","contribution":"Nichts","comment":"-"};
postRequest.write(JSON.stringify(guest));
postRequest.end();
var postOptions = {
host: 'localhost',
port: '8080',
path: '/api/events/3',
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
};
var postRequest = http.request(postOptions, function(response) {
response.setEncoding('utf8');
response.on('data', function (chunk) {
console.log('Response: ' + chunk);
});
});
// post the data
var data = {"targetGroup": "Studenten & Allumni", "contributionsDescription": "Kuchen oder anderes Dessert"}
postRequest.write(JSON.stringify(data));
postRequest.end();
var postOptions = {
host: 'localhost',
port: '8080',
path: '/api/events/2/guests/1',
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
};
var postRequest = http.request(postOptions, function(response) {
response.setEncoding('utf8');
response.on('data', function (chunk) {
console.log('Response: ' + chunk);
});
});
// post the data
var guestUpdateData = {"contribution":"Doch noch was"};
postRequest.write(JSON.stringify(guestUpdateData));
postRequest.end();
var postOptions = {
host: 'localhost',
port: '8080',
path: '/api/events/2/guests/1',
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
};
var postRequest = http.request(postOptions, function(response) {
response.setEncoding('utf8');
response.on('data', function (chunk) {
console.log('Response: ' + chunk);
});
});
// post the data
var guest = {canceled: true};
postRequest.write(JSON.stringify(guest));
postRequest.end();