The method getListItem(url: string) is used to perform REST calls against SharePoint. It returns a promise as an object that waits for a GET action to finish.
The getListItemRecursive is very straightforward. It invokes the getListItem method; if the result contains more than x numbers of items, the listing service will return an odata.nextLink property. With the promise, I’m able to get the odata.nextLink value in the then handler after the returned items are resolved. If the odata.nextLink value is not null, the getListItemRecursive method will call itself to retrieve the next set of results by sending the URL value of the odata.nextLink property to the getListItem process. The list service will continue to return a reference to the next set of data in the odata.nextLink property with each response until all of the results have been returned. The items collection is called only when each promise is fulfilled.
This function above is invoked to request getListItem, and supply a callback function that will later be invoked with the result.
The example above performs well in a SharePoint Framework web part. The asynchronous operation helps the overall performance and responsiveness of my application, particularly when accessing large datasets.