-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
52 lines (43 loc) · 1013 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const http = require('http');
var gates = [
{
gateName: 'Blue',
gateId: 0,
conditions:[]
},
{
gateName:'Green',
gateId: 0,
conditions:[]
},
{
gateName:'Orange',
gateId: 0,
conditions:[]
},
{
gateName: 'Red',
gateId: 0,
conditions:[]
}];
const uri = 'http://localhost:9000/api/qualitygates/show?name=';
gates.forEach( gate => {
console.log( uri + gate.gateName);
http.get( uri + gate.gateName, (resp) => {
let data = '';
// A chunk of data has been received.
resp.on('data', (chunk) => {
data += chunk;
});
// The whole response has been received. Print out the result.
resp.on('end', () => {
conditions = JSON.parse(data).conditions;
conditions.forEach(condition => {
gate.conditions.push(condition);
});
console.log(gate);
});
}).on("error", (err) => {
console.log("Error: " + err.message);
});
});