-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
49 lines (36 loc) · 1.16 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
const https = require('https');
//const process = require('process');
const fs = require('fs')
const { readFile } = require('fs/promises');
const { resolve } = require('path');
async function logFile() {
try {
const filePath = resolve('./gitreposlist.json');
const contents = await readFile(filePath, { encoding: 'utf8' });
console.log(contents);
const obj = JSON.parse(contents);
// obj.forEach( ( value , index, array ) => {
// console.log(` ${value.name} \n ${value.description} \n ${value.language} \n ${value.html_url} \n\n `);
// });
var myArray = obj.map( ( value , index , array ) => {
return {
name : value.name,
description: value.description,
language: value.language,
html_url: value.html_url
}
})
console.log(JSON.stringify(myArray));
} catch (err) {
console.error(err.message);
}
}
logFile();
// https.get ( 'https://api.github.com/users/astokum/repos', {
// "User-Agent": "curl/7.79.1",
// "X-GitHub-Api-Version": "2022-11-28"
// }, (res ) => {
// res.on('data', (d) => {
// process.stdout.write(d);
// });
// })