phoneNumbers is sometimes undefined
See original GitHub issueHey 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!
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
undefined is not an object (evaluating 'item.phoneNumbers[0]')
So far I have read that the reason this error comes up is because I should check first that a phone number exists...
Read more >getNumberType always return undefined for Indonesia Phone ...
Hi, I try to check whether my input is an Indonesia Phone Number or not by using getNumberType function, but i always get...
Read more >phoneNumbers is sometimes undefined · Issue #79 · joshuapinter ...
When someone has added a contact in iOS (and I assume the same in Android) without adding any phone numbers for them, the...
Read more >phonenumbers - PyPI
Python version of Google's common library for parsing, formatting, storing and validating international phone numbers.
Read more >libphonenumber-js - npm
For example, when dialing phone numbers within the same "area", people sometimes skip the "area code", and dial, say, 456-789 instead of ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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.
Excellent! Thanks in advance for your help!
A proper test suite is on the TODO list but nothing is setup yet.
The best way, as you mentioned, is to run the example app and make sure it’s all working as expected.
Let me know how it goes! On Jun 25, 2018, 2:56 PM -0600, Jimmy Thompson notifications@github.com, wrote: