-2

I'm looking for a snippet to get ids of friends who use my app.

I wrote this:

FB.api('/me/friends', function(response) {
    amis = response.data;
    console.log(amis[].id);
});

On login I asked for {scope:'public_profile , user_friends'});

andyrandy
  • 72,880
  • 8
  • 113
  • 130

1 Answers1

1

I am not sure what the problem is, but you can try this if you just want to output all ids:

FB.api('/me/friends', (response) => {
    if (response && response.data) {
        for (let i = 0; i < response.data.length; i++) {
            console.log(response.data[i].id);
        }
    }
});
andyrandy
  • 72,880
  • 8
  • 113
  • 130