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 options
object Properties
Name Type Argument Default Description amount
number The number of items to fetch.
skipReplies
boolean <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
skipReplies
is set totrue
, snoowrap uses reddit'sapi/info
endpoint to fetch Comments. WhenskipReplies
is set tofalse
, snoowrap uses reddit'sapi/morechildren
endpoint. It's worth noting that reddit does not allow concurrent requests to theapi/morechildren
endpoint by the same account.append
boolean <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.append
istrue
, 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 abefore
query 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 options
object <optional>
Fetching options -- see
Listing#fetchMore
Returns:
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 { ... }, ... ]