What's best solution to getAllFriends from Facebook API?

Hi,

I’m not sure which is the best method to get all friends from Facebook API.

I try the recursive method :

  getAllFriends() {
    return new Promise((resolve, reject) => {
      let me = this
      let friends = []
      let recursiveAPICall = (url) => {
        me.fb.api(url, ['user_friends']).then(response => {
          if (response && response.data)
          {
            friends = friends.concat(response.data)

            if (response.paging && response.paging.next) {
              recursiveAPICall('/me/taggable_friends?after=' + response.paging.cursors.after)
            }
            else { resolve(friends) }
          }
          else { resolve(response) }
        })
      }
      recursiveAPICall('/me/taggable_friends')
    })
  }

I try the “limit” method

  getFriends() {
    return new Promise((resolve, reject) => {
      let array = [];
      return this.fb.api('/me/taggable_friends?limit=500000', ['user_friends']).then(res => {
        array = array.concat(res.data)
        if(res.paging && res.paging.next) {
          return this.fb.api(res.paging.next, ['user_friends']).then(res2 => {
            array = array.concat(res2.data)
            resolve(array)
          })
        }
      })
    })
  }

Thanks for your suggests