Angular multiple http requests chrome android

180 views Asked by At

I got an issue retrieving a lot of data from an api on chrome android.

This issue only appear on chrome android and may be other mobile devices.

First i tried to retrieve json in one request but i think that 15000 objects i'm retrieving from the json is far too big for chrome android to handle.

So i tried to slice this request into multiples to retrieve parts of what i need.

Even with this solution chrome android barely retrieve more than 3000 objects and after this every request are in waiting status on the debugger.

Here is the code:

$http.get(MangaEdenApiInfos.baseApiUrl + '/list/0/?p=0').then(function(result) {

  var nbMangas = 500;
  var nbPages = result.data.total / nbMangas;
  var requests = [];

  for (var i = 1; i < nbPages; ++i) {
    requests.push($http.get(MangaEdenApiInfos.baseApiUrl + '/list/0/?p=' + i + '&l=' + nbMangas));
  }

  $q.all(requests).then(function (results) {
    console.log(results);
  }, function (error) {
    console.log(error);
  });
});

The code never end neither in success or error promise callback.

Have you any idea of what i'm doing wrong?

Or may be i should load with pagination my data?

Thanks in advance!

0

There are 0 answers