我正在创建一个投资组合网站,其中包含最近的Github提交部分。我使用React / Redux和Axios来从Github API获取提交。目前,我可以获得ONE repo的最新提交,但我想要几乎所有提交的活动提要。
https://api.github.com/repos/CodeAmend/portfolio/commits?per_page=3", null, config);
- 正如Harald Nordgren在他的帖子中提到的那样......
目前,这仅显示ONE repo的提交。我正在寻找我帐户上所有提交的Feed。
如果无法使用Github API,那么我必须创建一个自定义函数,但这需要下载所有repos并按axios.get("https://api.github.com/users/CodeAmend/repos", null, config);
对它们进行排序并对push_at字段进行排序。这仍然没有给我最新的提交(如果在同一个项目中有多个提交)。
renderLatestCommits(latestCommitListLength = 3) { // custom React render method
const recentCommits = [];
this.props.commits.map( (commit => {
addIfLatestCommit(commit);
return recentCommits.map(recentCommit => {
return <div>{recentCommit.name}</div>;
}
}
}
我在这里找出是否需要构建addIfLatestCommit()函数。
如果我想查看Github文档,我会在哪里看。我看过Github commits documentation
编辑:我的github项目是here
答案 0 :(得分:3)
简单明了,从终端运行它可以获得存储库中的5个最新提交:
curl "https://api.github.com/repos/CodeAmend/portfolio/commits?per_page=5"
您必须弄清楚如何从JavaScript代码发出HTTP请求并处理返回数据,但这是正确的URL。