Get Facebook profile picture

Hi, i’m rly new to facebook OAuth and i’m struggling to get the user profile picture.
I have the following code (based on this Stack question StackOverflow Question):

Facebook.login(['email']).then((response) => {
        console.log(JSON.stringify(response.authResponse));
        Facebook.getLoginStatus().then((response) => {
            if (response.status == 'connected') {
                Facebook.api('/' + response.authResponse.userID + '?fields = id,name,birthday', []).then(data => {
                    //Get the user data
                    let user = {
                        access_token: response.authResponse.accessToken,
                        nome: data.name,
                        nascimento: data.birthday,
                        id: data.id
                    }
                    //Get the user profile picture and save in user object
                    Facebook.api(`/` + response.authResponse.userID + `?fields = picture?redirect=false`, []).then(data => {
                        user['foto_perfil'] = data.url;
                        this.navCtrl.push(UsuarioPerfilPage, user);
                    });
                })
            }
        });
    }

I removed all the errors callback bcause it’s not throwing any error.
This is my user object:
image
(yeah i’m not getting the birthday either, but i’m working on it).

So, can anyone give me a light of what am i doing wrong? Can’t managed to find help on anyother site or blog.
Thanks everyone.

1 Like