moderator-toolbox-nxg-for-reddit / api/transport/pagination
api/transport/pagination¶
Functions¶
fetchAllListingPages()¶
fetchAllListingPages<
T>(fetchPage,options?):Promise<T[]>
Defined in: extension/data/api/transport/pagination.ts:30
Fetches all pages from a Reddit listing endpoint using an after cursor,
collecting data.children across all pages into a single array.
Stops when the response has no after cursor, when a page returns no
children, or when options.maxCount items have been accumulated.
Type Parameters¶
T¶
T
Parameters¶
fetchPage¶
(after) => Promise<{ data: { after: string | null | undefined; children: T[]; }; }>
Called for each page; receives the after cursor from the
previous response (undefined on the first call) and must return a Reddit
listing response containing data.children and data.after.
options?¶
maxCount?¶
number
Stop after accumulating at least this many items.
maxRetries?¶
number
Maximum total attempts per page when a 504 Gateway Timeout is encountered. Defaults to 1 (first failure throws immediately).
Returns¶
Promise<T[]>
is504()¶
is504(
error):boolean
Defined in: extension/data/api/transport/pagination.ts:11
Reports whether a caught value represents a 504 Gateway Timeout response,
which callers may safely retry. Accepts any thrown value - only objects
carrying a response.status of 504 match - so it works for both
RequestError instances and plain {response: {status}} shapes. Defined
here (rather than in http) so it carries no browser-extension dependency.
Parameters¶
error¶
unknown
The caught value to inspect.
Returns¶
boolean