Home > database >  how to manipulate a custom attribute 'custom:variable_name' in Javascript
how to manipulate a custom attribute 'custom:variable_name' in Javascript

Time:03-16

So, using AWS Cognito I created a custom attribute (special_name) which I can access using axios and AWS's Auth.currentUserInfo(). Using my browser's JavaScript console I can see the variable as:

attributes: custom:special_name: 'foo'

Great.

But if I console.log(custom:special_name) I get errors or at best 'undefined'

I'm using Visual Studio Code which really doesn't like the format custom:special_name.

I've already searched on this site and the ideas given, e.g. ['custom: special_name'] also don't work.

I feel like I'm missing something very obvious.

Please put me out of my misery.

Thanks.

CodePudding user response:

But if I console.log(custom:special_name) I get errors or at best 'undefined'

Did you mean:

attributes['custom:special_name']

It seems your variable is a member of the attributes object, not a global one. In that case, the square bracket syntax will work.

  • Related