How to import contact list from gmail using API in angular5?

477 views Asked by At

I am using this code to import contact list from google. Everything is fine, but unable to get any result from the same.

fetchmail() method is returning: ERROR {}

Here is my fetchmail() method:

fetchmail() {
console.log("check6");
gapi.load('client: auth2', () => {
  console.log('check7');
  gapi.auth2.getAuthInstance({
    apiKey: 'APIKEY',
    discoveryDocs: ['https://people.googleapis.com/$discovery/rest?version=v1'],
    clientId: '<MyClientID>.apps.googleusercontent.com',
    scope: 'profile email https://www.googleapis.com/auth/contacts.readonly'
  }).then(() => {
    console.log('check8');
    return gapi.client.people.people.connections.list({
      resourceName: 'people/me',
      personFields: 'emailAddresses, names'
    });
  }).then(
    (res) => {
      console.log("Res: " + JSON.stringify(res));
      this.userContacts.emit(this.transformToMailListModel(res.result));
      console.log("Res:" + JSON.stringify(res.result));
    },
    error => console.log("ERROR " + JSON.stringify(error))
  );
});

And from the browser console i am getting this result:

enter image description here

Can anyone please help me find the problem or suggest a fix for the same.

Thanks in advance!

0

There are 0 answers