Skip to content

Instantly share code, notes, and snippets.

@amowu amowu/getAllCommits$.js
Last active Oct 22, 2018

What would you like to do?
GitHub API pagination with RxJS
const GitHubApi = require("github");
const Rx = require("rx");
const github = new GitHubApi();
const getCommitsAsync = (param) => github.repos.getCommits({
owner: 'amowu',
repo: 'test-semantic-release',
const checkNextPage = (response) =>
? Rx.Observable.fromPromise(github.getNextPage(response))
: Rx.Observable.empty();
const concatAllCommits = (acc, curr) => acc.concat(;
const getAllCommits$ = Rx.Observable
.fromPromise(getCommitsAsync({ per_page: 100 }))
.reduce(concatAllCommits, []);
// getAllCommits$.subscribe(
// (commits) => console.log(commits)
// );
const commits = await getAllCommits$.toPromise();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.