Async data paging in Javascript

hi there,
When I run the code described here: in JS, even for the Async method, I get: “[Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience. For more help, check”
As a warning in my browser. The call without pagination does not trigger the warning (as it is using the callback), however with pagination I get this problem (subsequent calls seem to be synchronous?). Any recommendation?
Thank you

Hi Marco

Please provide a code snippet which causes the warning.

Thanks, Vlad

the code that you can see in the example (I’m on backendless 3.1.18):

function handleResponse (restaurants) {    console.log("Total restaurants - " + restaurants.totalObjects);    var size =;    console.log( "Loaded " + size + " restaurants in the current page" );    var nextPage = restaurants._nextPage;     while (nextPage) {    restaurants = restaurants.nextPage();    size =;    console.log( "Loaded " + size + " restaurants in the current page" );    nextPage = restaurants._nextPage;    }    console.log("Total time (ms) - " + ((new Date()).getMilliseconds() - this.startTime));} function handleFault (backendlessFault) {    console.log("Server reported an error - ");    console.log(backendlessFault.message);    console.log(backendlessFault.statusCode);} function basicPagingAsync () {    try {        this.startTime = (new Date()).getMilliseconds();	var callback = new Backendless.Async(handleResponse, handleFault);	Backendless.Persistence.of(Restaurant).find(callback);    }    catch (e) {	throw e.message;    }} Backendless.initApp (APP_ID, SECRET_KEY, VERSION);basicPagingAsync();

according to JS-SDK 3.x sources

you need to pass async callback to “nextPage” and “getPage” methods

for make the requests asynchronous

thanks Vladimir, I’ll try this.

is there an example on how to do this using Promises? I see pagination is discussed in the documentation only for certain libraries (for example ios/android) but not for JS. Thank you.

I’m not sure our JS SDK for version 3 supports Promises out of the box. You’ll have you add this support by your own if you need, but our v3 SDK can only work with callbacks (when you need async).

Here is an example you are looking for

function findAllPlaceHits returns a Promise which will supply all objects in the Place_Hits table

thanks a lot Vitaly, sorted it out using your function.