Get More than 5000 records from SharePoint list by rest API through recursive call
--------------------------------------------------------------------------------
$(document).ready(function(){
GetListItems();
});
var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('ECO_Documents')/items?$top=4999&$orderby=ID";
var response = response || []; // this variable is used for storing list items
function GetListItems(){
return $.ajax({
url: url,
method: "GET",
headers: {
"Accept": "application/json; odata=verbose"
},
success: function(data){
response = response.concat(data.d.results);
if (data.d.__next) {
url = data.d.__next;
// console.log(url);
GetListItems();
}
},
error: function (error) {
alert(JSON.stringify(error));
}
});
}