Advertisement
rg443

window.fetch(), queue_len=5

Oct 26th, 2015
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // window.fetch(), queue_len=5
  2. var page = 1, pages = 1E3, ql = 1, maxql = 5, pageu = 1, photos = [];
  3. call1(page);
  4. function call1(page) {
  5.   fetch("https://api.500px.com/v1/photos/?feature=popular&rpp=100&tags=1&image_size=3,4,2048&consumer_key=cGxWLkAk4zp6XK8mkz95UR7ksy17FsEPo8VfXBCm&page=" + page).then(function(response) {
  6.     return response.json();
  7.   }).then(function(v) {
  8.     console.log(v);
  9.     photos = photos.concat(v.photos);
  10.     ql--;
  11.     v.total_pages && v.total_pages < 1E3 && (pages = v.total_pages);
  12.     while (pageu < pages && ql < maxql) {
  13.       pageu++;
  14.       ql++;
  15.       call1(pageu);
  16.     }
  17.   });
  18. }
  19. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement