rcs-business-messaging / rbm-api-examples

Apache License 2.0
17 stars 9 forks source link

I'm having issues with rbmApiHelper.checkCapability for a single phone number. Perhaps it's related to the bulk capability check problems? #4

Closed knutesears closed 9 months ago

knutesears commented 9 months ago

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.

rbmApiHelper.checkCapability(phoneNumber,
    function(response, err) {

        console.log(err)
        //console.log("============================")
        //console.log(response)
/*
        if (err !== undefined) {
            console.log(util.inspect(err, {showHidden: false, depth: null, colors: true}))
        }
        if (response !== undefined) {
            console.log(util.inspect(response, {showHidden: false, depth: null, colors: true}))
        }
*/
    }
)

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