EDIT: Never mind; I'm an idiot; the checkCapability function was logging things itself as well as returning them; please close; sorry.
I was getting two responses logged to the console whilst checking one phone number. Upon fiddling with the callback function, it seems that both the response and err(or) args are args are being fed the response object.
Note the null tacked on the end, which you don't get at the end of the response var when it's returned. If there's a real error, you get it with no null at the end, and response is undefined. Easy workaround is to just check response first, and only look at error if response is undefined (or maybe null;), which should be future-proof for when bug is fixed, if done right. Hope this helps.
EDIT: Never mind; I'm an idiot; the checkCapability function was logging things itself as well as returning them; please close; sorry.
I was getting two responses logged to the console whilst checking one phone number. Upon fiddling with the callback function, it seems that both the response and err(or) args are args are being fed the response object.
This code /logs/ only the error -- after commenting out most everything else. And it produces this for a valid number :
{ config: { [STUFF] }, data: { features: [ 'RICHCARD_STANDALONE', 'ACTION_CREATE_CALENDAR_EVENT', 'ACTION_DIAL', 'ACTION_OPEN_URL', 'ACTION_SHARE_LOCATION', 'ACTION_VIEW_LOCATION', 'RICHCARD_CAROUSEL' ] }, headers: { [STUFF] }, status: 200, statusText: 'OK', request: { [STUFF] } } null
Note the null tacked on the end, which you don't get at the end of the response var when it's returned. If there's a real error, you get it with no null at the end, and response is undefined. Easy workaround is to just check response first, and only look at error if response is undefined (or maybe null;), which should be future-proof for when bug is fixed, if done right. Hope this helps.
Originally posted by @knutesears in https://github.com/rcs-business-messaging/rbm-api-examples/issues/3#issuecomment-1924428631