-
-
Notifications
You must be signed in to change notification settings - Fork 92
/
index.js
38 lines (33 loc) · 828 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
import { normalize } from '@data-client/normalizr';
import fs from 'fs';
import https from 'https';
import path from 'path';
import * as schema from './schema';
let data = '';
const request = https.request(
{
host: 'api.github.com',
path: '/repos/reactive/data-client/issues',
method: 'get',
headers: {
'user-agent': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)',
},
},
res => {
res.on('data', d => {
data += d;
});
res.on('end', () => {
const normalizedData = normalize(
JSON.parse(data),
schema.IssueOrPullRequest,
);
const out = JSON.stringify(normalizedData, null, 2);
fs.writeFileSync(path.resolve(__dirname, './output.json'), out);
});
res.on('error', e => {
console.log(e);
});
},
);
request.end();