Skip to content

Instantly share code, notes, and snippets.

@mohandere
Last active February 19, 2018 14:53
Show Gist options
  • Save mohandere/cd2801fbafb4e034fd8bb3fc29db6e07 to your computer and use it in GitHub Desktop.
Save mohandere/cd2801fbafb4e034fd8bb3fc29db6e07 to your computer and use it in GitHub Desktop.
Epic get github user repos
import { ajax } from 'rxjs/observable/dom/ajax';
import 'rxjs/add/operator/catch'
import {
REQUEST_USER_REPOS_START
} from '../actions/actionTypes';
import {
doUserReposFulfilled,
doUserReposFailed
} from '../actions/doUserRepos';
// epic
const epicGetUserRepos = action$ => {
return action$.ofType(REQUEST_USER_REPOS_START)
.mergeMap(action =>
ajax.getJSON(`https://api.github.com/users/${action.username}/repos`)
.map(response => doUserReposFulfilled(response))
.catch(error => doUserReposFailed(error))
);
}
export default epicGetUserRepos;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment