-
Notifications
You must be signed in to change notification settings - Fork 204
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
README: Example on getting the tokens you should remove #323
Conversation
Include example of how to find the tokens which you couldn't send to. I'm maching the two arrays together and then filtering it to get a list of tokens.
README.md
Outdated
sender.send(message, { registrationTokens: registrationTokens }, function (err, response) { | ||
var failed_tokens = response.results | ||
.map((res, i) => !!res.error ? registrationTokens[i] : undefined) | ||
.filter(token => !!token); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the time you took to contribute 😄
Here are my thoughts:
Isn't the code wrong, mapping all responses without errors (where res.error
is falsy, so !!res.error == false
) to undefined
? Shouldn't it be the opposite?
I would prefer using null
to undefined
in the code example, too.
In addition, I think the !!
are adding confusion, as the evaluation would be the same without them...
Other than that, it is a good example 😄
Thanks for the quick update 😄 I still think the check for res.error might be wrong --- shouldn't it be |
My thinking is that the |
Ah yes, you are absolutely right, I was just reading it wrong! I blame being tired 😄 Maybe we could avoid people like me misunderstanding the code in the future by adding a bit more of a comment? |
This looks good to me! Remember to add yourself to contributors in package.json 😄 @eladnava any comments on this before we merge? |
Just reviewed, looks good to me! 💯 Thanks so much @johanforssell for the excellent work. |
Thanks for the contribution @johanforssell ! 😄 |
Example of how to find the tokens which you couldn't send to.
I'm maching the two arrays together and then filtering it to get a list of tokens.