Skip to content

Instantly share code, notes, and snippets.

@mcgrue
Created February 24, 2016 05:57
Show Gist options
  • Select an option

  • Save mcgrue/3735c2f28419db6c00be to your computer and use it in GitHub Desktop.

Select an option

Save mcgrue/3735c2f28419db6c00be to your computer and use it in GitHub Desktop.
/// not public, but I want to test it.
export function fetchPosts(subreddit) {
return (dispatch) => {
dispatch(requestPosts(subreddit));
const url = `http://www.reddit.com/r/${subreddit}.json`;
return fetch(url)
.then((req) => { return req.json(); })
.then((json) => { dispatch(receivePosts(subreddit, json)); });
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment