-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (27 loc) · 890 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
const fs = require('fs').promises
const axios = require('axios');
require('dotenv').config()
async function getData(url){
var config = {
method: 'get',
url: url,
headers: {
'Authorization': process.env.SECRET_KEY
}
};
const res = await axios(config)
// console.log('after the call to service');
// console.log(res.data.count)
return (res.data.count);
}
(async()=>{
const views = await getData('https://api.github.com/repos/nach131/get_next_line/traffic/views');
const clone = await getData('https://api.github.com/repos/nach131/get_next_line/traffic/clones');
const MarkdownTemplate = await fs.readFile('./README.md.tpl', { encoding: 'utf-8' })
// console.log(views,clone)
const newMarkdown = MarkdownTemplate
.replace('total_views', views)
.replace('total_clone', clone)
// console.log(newMarkdown);
await fs.writeFile('./README.md', newMarkdown)
})();