Fetcher
Direct Subclass:
Base api fetcher.
Constructor Summary
Public Constructor | ||
public |
constructor(http: Http, territory: string) |
Method Summary
Public Methods | ||
public |
fetchNextPage(fulfillment: fulfillment, nextUriPath: String): Promise Fetches next page of various paged APIs. |
|
public |
hasNextPage(fulfillment: fulfillment, nextUriPath: String): Boolean Is next page available for various paged APIs. |
|
public |
setTerritory(territory: string): Fetcher Set the fetcher's territory. |
Public Constructors
Public Methods
public fetchNextPage(fulfillment: fulfillment, nextUriPath: String): Promise source
Fetches next page of various paged APIs.
Params:
Name | Type | Attribute | Description |
fulfillment | fulfillment | The fulfillment get from Promose's onFulfillment function |
|
nextUriPath | String | The next uri's path. Defaults to 'data.paging.next', which means we will get the next uri path from 'fulfillment.data.paging.next'. The correct next uri path depends on respective api's response. |
Example:
api.albumFetcher
.setAlbumID('KmRKnW5qmUrTnGRuxF')
.fetchTracks()
.then(response => {
api.albumFetcher.fetchNextPage(response));
});
public hasNextPage(fulfillment: fulfillment, nextUriPath: String): Boolean source
Is next page available for various paged APIs.
Params:
Name | Type | Attribute | Description |
fulfillment | fulfillment | The fulfillment get from Promose's onFulfillment function |
|
nextUriPath | String | The next uri's path. Defaults to 'data.paging.next', which means we will get the next uri path from 'fulfillment.data.paging.next'. The correct next uri path depends on respective api's response. |
Example:
api.albumFetcher
.setAlbumID('KmRKnW5qmUrTnGRuxF')
.fetchTracks()
.then(response => {
if (api.albumFetcher.hasNextPage(response)) {
// more data available
}
});