Quantcast
Channel: OBSOLETE - Soapi.JS : fluent JavaScript client library for the Stack Exchange API - Stack Apps
Viewing all articles
Browse latest Browse all 16

Answer by Sky Sanders for OBSOLETE - Soapi.JS : fluent JavaScript client library for the Stack Exchange API

$
0
0

Paging Operations

The majority of operation against the API involve paging operations.

Most of the work and complexity of dealing with paged results have been encapsulated by the Route.GetPagedResponse() method.

Soapi.RouteFactory("api.stackoverflow.com", apiKey).Tags({ pagesize: 1 }) // contrived page size.getPagedResponse(function success(aggregatedPages){    // when the paging operation completes, whether due to completion of    // paging or arbitrary termination in pageCallback, the aggregated data is    // returned to this, the success handler.    // should be the aggregated total of 10 pages of 1 item or simply 10    alert(aggregatedPages.items.length);}, function failure(error){    // handle the error}, function pageCallback(currentPage){    // you can handle the data page by page in this handler or     // aggregated in total in the success handler    // simply omit this function parameter if you want all     // pages returned to the success handler    // return true from this function to terminate paging operation     // and return currently aggregated data to success handler.    // we will report progress on the paging operation and constrain    // the paging operation to 10 pages    reportProgress(currentPage.page);    // return true to terminate operation    return currentPage.page == 10;});

Next: VectorizedIdList - reliably maximize request payload


Viewing all articles
Browse latest Browse all 16

Trending Articles