Support Topics Documentation Slack YouTube Blog

err.statusCode is UNDEFINED (JavaScript)


(Pawel Lenart) #1

Hi,

I have one more problem. I use the login and registration functions to register or login as a user. Basically it works and I get nice Error Messages, when i enter some info wrong, but, i do not get the Error Code.

In your Docu, you write, that the message / error code can be retrieved by:

err.message
err.statusCode

err.message works (i get the message), but err.statusCode is ALWAYS “undefined”.

I use the latest version of your API.

Is this a Bug?

Cheers,
Pawel


(Mark Piller) #2

Hi Pawel,

Have you tried checking in the debugger what you get back from the server?

Regards,
Mark


(Pawel Lenart) #3

Hi Mark,

yes, this is what i see in the console, when i do:

function gotError( err ) {

console.log(err);

}

It seems, that the err variable contains just the string and is not really an object (otherwise chrome would show me some expand / drill down options).

Any idea what could be wrong?

You can find my script here: https://uxjax.com/register.html

Many thanks in advance!

P.


(Mark Piller) #4

HI Pawel,

I believe the property name is errorCode (need to correct it in our docs). You can confirm it with the following code:
console.log( JSON.stringify( err ) );

Could you please check and confirm?

Regards,
Mark


(Pawel Lenart) #5

Hi Mark!
sorry, forgot to stringify :slight_smile: Seems that the right poroperty is called “code” :wink:

Here the output:

{“status”:400,“headers”:{“content-type”:“application/json”},“message”:“Unable to register user. Missing required property value for ‘password’”,“code”:3041}

Many thanks! :slight_smile: