-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrequest.js
32 lines (26 loc) · 825 Bytes
/
request.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
module.exports = function (opt) {
return new Promise((resolve, reject) => {
const https = require('follow-redirects').https;
var options = opt || {
'method': 'GET',
'hostname': 'software.astrogd.eu',
'path': '/ticketsystem/version.json',
'headers': {},
'maxRedirects': 20
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
resolve(body);
});
res.on("error", function (error) {
reject(error);
});
});
req.end();
});
}