mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-11-28 18:28:04 -08:00
refresh data sources close #73
This commit is contained in:
1 parent
6f260a6ac7
commit
fb93ade4d2
18 files changed
+21194
-26727
No files matched your search
@@ -0,0 +1,25 @@
|
||||
// async https wrapper
|
||||
import https from 'https';
|
||||
|
||||
const get = (url) => new Promise((resolve, reject) => {
|
||||
const headers = {};
|
||||
headers['user-agent'] = '(WeatherStar 4000+ data generator, ws4000@netbymatt.com)';
|
||||
|
||||
https.get(url, {
|
||||
headers,
|
||||
}, (res) => {
|
||||
if (res.statusCode === 200) {
|
||||
const buffers = [];
|
||||
res.on('data', (data) => buffers.push(data));
|
||||
res.on('end', () => resolve(Buffer.concat(buffers).toString()));
|
||||
} else {
|
||||
console.log(res);
|
||||
reject(new Error(`Unable to get: ${url}`));
|
||||
}
|
||||
}).on('error', (e) => {
|
||||
console.log(e);
|
||||
reject(e);
|
||||
});
|
||||
});
|
||||
|
||||
export default get;
|
||||
Reference in new issue
Block a user