File size: 939 Bytes
3206347
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
export default {
  name: 'List albums',
  key: 'listAlbums',

  async run($) {
    const params = {
      page: 1,
      per_page: 500,
      user_id: $.auth.data.userId,
      method: 'flickr.photosets.getList',
      format: 'json',
      nojsoncallback: 1,
    };

    let response = await $.http.get('/rest', { params });

    const aggregatedResponse = {
      data: [...response.data.photosets.photoset],
    };

    while (response.data.photosets.page < response.data.photosets.pages) {
      response = await $.http.get('/rest', {
        params: {
          ...params,
          page: response.data.photosets.page,
        },
      });

      aggregatedResponse.data.push(...response.data.photosets.photoset);
    }

    aggregatedResponse.data = aggregatedResponse.data.map((photoset) => {
      return {
        value: photoset.id,
        name: photoset.title._content,
      };
    });

    return aggregatedResponse;
  },
};