Created
April 1, 2013 03:13
-
-
Save wmill/5283049 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.RedditLink.reopenClass({ | |
/* Use the Reddit JSON API to retrieve a list of links within a subreddit. Returns | |
a promise that will resolve to an array of `App.RedditLink` objects */ | |
findAll: function(subreddit) { | |
return $.getJSON("http://www.reddit.com/r/" + subreddit + "/.json?jsonp=?").then(function(response) { | |
var links = []; | |
response.data.children.forEach(function (child) { | |
links.push(App.RedditLink.create(child.data)); | |
}); | |
return links; | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment