-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.js
More file actions
35 lines (32 loc) · 733 Bytes
/
api.js
File metadata and controls
35 lines (32 loc) · 733 Bytes
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
var http = require('http');
var constants = require('./constants');
function sendReport(report) {
return new Promise(function(resolve, reject){
var options = {
hostname: constants.apiHost,
port: 80,
path: constants.apiPath,
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
};
var req = http.request(options, function(res) {
res.setEncoding('utf8');
res.on('data', function (body) {
resolve();
return;
});
});
req.on('error', function(e) {
console.log(e.message);
resolve();
return
});
req.write(JSON.stringify(report));
req.end();
});
}
module.exports = {
sendReport: sendReport
};