-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyncdb.js
54 lines (50 loc) · 1.23 KB
/
syncdb.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
var exec = require('child_process').exec,
child;
var request = require('request');
child = exec('node dropdb.js',
function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
var options = {
method: 'GET',
uri: 'https://smartcity.rbccps.org/api/0.1.0/cat',
json: true,
rejectUnauthorized: false,
headers: {
'Content-Type': 'application/json'
}
}
request(options, function(err, response, body) {
if (!err) {
var itemsArr = body.items;
for (var i = 0; i < itemsArr.length; i++) {
var options1 = {
method: 'POST',
uri: 'http://localhost:8001/cat',
qs: {
id: itemsArr[i].id,
},
json: itemsArr[i],
rejectUnauthorized: false,
headers: {
'Content-Type': 'application/json',
'no-check': true,
'pwd': 'cat123'
}
}
request(options1, function(err, response, body) {
if (!err) {
console.log(body);
} else {
console.log(err);
}
});
};
} else {
console.log(err);
}
});
});