new Listing()
Extends
- Array
Members
-
isFinished :boolean
A getter that indicates whether this Listing has any more items to fetch.
-
Type:
- boolean
Methods
-
fetchMore(options)
Fetches some more items
-
Parameters:
Name Type Description optionsobject Properties
Name Type Argument Default Description amountnumber The number of items to fetch.
skipRepliesboolean <optional>
false For a Listing that contains comment objects on a Submission, this option can be used to save a few API calls, provided that only top-level comments are being examined. If this is set to
true, snoowrap is able to fetch 100 Comments per API call rather than 20, but all returned Comments will have no fetched replies by default.Internal details: When
skipRepliesis set totrue, snoowrap uses reddit'sapi/infoendpoint to fetch Comments. WhenskipRepliesis set tofalse, snoowrap uses reddit'sapi/morechildrenendpoint. It's worth noting that reddit does not allow concurrent requests to theapi/morechildrenendpoint by the same account.appendboolean <optional>
true If
true, the resulting Listing will contain the existing elements in addition to the newly-fetched elements. Iffalse, the resulting Listing will only contain the newly-fetched elements.Returns:
A new Listing containing the newly-fetched elements. If
options.appendistrue, the new Listing will also contain all elements that were in the original Listing. Under most circumstances, the newly-fetched elements will appear at the end of the new Listing. However, if reverse pagination is enabled (i.e. if this Listing was created with abeforequery parameter), then the newly-fetched elements will appear at the beginning. In any case, continuity is maintained, i.e. the order of items in the Listing will be the same as the order in which they appear on reddit.- Type
- Promise
Example
r.getHot({limit: 25}).then(myListing => { console.log(myListing.length); // => 25 myListing.fetchMore({amount: 10}).then(extendedListing => { console.log(extendedListing.length); // => 35 }) }); -
fetchAll( [options])
Fetches all of the items in this Listing, only stopping when there are none left.
-
Parameters:
Name Type Argument Description optionsobject <optional>
Fetching options -- see
Listing#fetchMoreReturns:
A new fully-fetched Listing. Keep in mind that this method has the potential to exhaust your ratelimit quickly if the Listing doesn't have a clear end (e.g. with posts on the front page), so use it with discretion.
- Type
- Promise
Example
r.getMe().getUpvotedContent().fetchAll().then(console.log) // => Listing [ Submission { ... }, Submission { ... }, ... ]