-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
25 lines (23 loc) · 686 Bytes
/
Copy pathindex.js
File metadata and controls
25 lines (23 loc) · 686 Bytes
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
'use strict';
const axios = require('axios');
const getRepos = async ({
username = 'vkalta',
page = 1,
per_page = 31
} = {}) => {
try {
const repos = await axios.get(`https://api.github.com/users/${username}/repos?page=${page}&per_page=${per_page}&sort=updated`);
return repos.data.map((repo) => {
return {
name: repo.name,
url: repo.html_url,
description: repo.description,
stars: repo.stargazers_count
};
})
.sort((first, second) => second.stars - first.stars);
} catch (error) {
return [];
}
};
module.exports = { getRepos };