-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
26 lines (24 loc) · 734 Bytes
/
Copy pathindex.js
File metadata and controls
26 lines (24 loc) · 734 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
26
// Import
const axios = require('axios');
// Function Definition
const getRepos = async({
username = 'LilJuiceBox491',
page = 1,
per_page = 30
} = {}) => {
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 [];
}
};
// Export
module.exports = { getRepos };