Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phoneNumbers is sometimes undefined #79

Open
jimmythompson opened this issue Jun 21, 2018 · 5 comments
Open

phoneNumbers is sometimes undefined #79

jimmythompson opened this issue Jun 21, 2018 · 5 comments

Comments

@jimmythompson
Copy link

Hey folks,

When someone has added a contact in iOS (and I assume the same in Android) without adding any phone numbers for them, the return value from the getContacts call is a little weird.

In this case, I expected the getContacts call to return an empty list:

{
  contacts: [{
    phoneNumbers: []
  }]
}

But, at least as of 0a67cdb, it omits the field entirely from the result:

{
  contacts: [{}]
}

We just got burned by this. Is this something you'd be open to changing?

It means we now have to do a sanity check on the field before playing with the phone numbers:

e.g. contact.phoneNumbers && contact.phoneNumbers.map(...)

Thank you!

@jimmythompson jimmythompson changed the title phoneNumbers is sometimes null phoneNumbers is sometimes undefined Jun 21, 2018
@joshuapinter
Copy link
Owner

Thanks for the issue!

So you'd like to see all the keys, even if they are empty, correct?

@jimmythompson
Copy link
Author

Yes please, for lists at least. 😄

@joshuapinter
Copy link
Owner

I think I agree with that API. Makes sense to have an empty key but at least have the key present. Allows you to loop through that key's Array without having to check for its presence. When it's empty, the loop just doesn't do anything.

Let's add this to the next major release.

@jimmythompson
Copy link
Author

Hey @joshuapinter, I'd like to fix this. 😄

As it's hard to put in automated tests, is there any standard way you check it all works? Maybe run the example app?

@joshuapinter
Copy link
Owner

joshuapinter commented Jun 25, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants