index.js
function _fetchSubreddit(subreddit) {
  const reducer = (prev, {data: {url}}) => prev.push(url) && prev;
  const jsonUri = `https://www.reddit.com/r/${subreddit}/.json`;
  return fetch(jsonUri)
    .then((res) => res.json())
    .then((res) => res.data.children.reduce(reducer, []))
    .then((urls) => ({subreddit, urls}));
}
function _fetchSubreddit(subreddit) {
  const reducer = (prev, {data: {url}}) => prev.push(url) && prev;
  const jsonUri = `https://www.reddit.com/r/${subreddit}/.json`;
  return fetch(jsonUri)
    .then((res) => res.json())
    .then((res) => res.data.children.reduce(reducer, []))
    .then((urls) => ({subreddit, urls}));
}
function _fetchSubreddit ( subreddit ) { const reducer = ( prev , { data : { url } } ) => prev . push ( url ) && prev ; const jsonUri = ` ${ subreddit } ` ; return fetch ( jsonUri ) . then ( ( res ) => res . json ( ) ) . then ( ( res ) => res . data . children . reduce ( reducer , [ ] ) ) . then ( ( urls ) => ( { subreddit , urls } ) ) ; }
Internal method to fetch the JSON feed and extract the URLs.
@private
@param  {String} subreddit Subreddit name to fetch JSON feed for.
@return {Object} An object containing the subreddit name as a key, and links as a nested array.
Internal method to fetch the JSON feed and extract the URLs .