君子之学,博于外而尤贵精于内。——王廷相

文档如下:

https://docs.github.com/zh/rest/orgs/orgs?apiVersion=2022-11-28

代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
const response = await fetch('https://api.github.com/orgs/dromara/repos?per_page=100&page=1');
if (!response.ok) {
throw new Error(`Error fetching repos: ${response.statusText}`);
}
const repos = await response.json();
console.log(repos)
const list = repos.map(({name,stargazers_count})=>({name,stargazers_count}))
console.log(list)
list.reduce(
(accumulator, currentValue) => accumulator + currentValue.stargazers_count,
0,
);

注意这里是分页,我们把每一页的结果相加,得到githubdromara82个仓库拥有89972star

apache则非常之多,2659个仓库1122875star