question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

phoneNumbers is sometimes undefined

See original GitHub issue

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!

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
joshuapintercommented, Jun 22, 2018

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.

0reactions
joshuapintercommented, Jun 25, 2018

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:

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? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found