I need to get some custom attributes from Cognito, and to do something with that info.
I have this function:
const getMyAttribute = async (): string => {
const userInfo = await Auth.currentUserInfo();
console.log('userInfo', userInfo);
return userInfo.attributes['custom:myAttribute']
};
And I'm calling it here in some React Component with:
const myAttribute = getMyAttribute();
console.log('myAttribute:', myAttribute); // Here is weird output
// Here I need to do something with `myAttribute`
In console.log I'm getting this:
myAttribute: {"_40": 0, "_55": null, "_65": 0, "_72": null}
userInfo: {"attributes": {"custom:myAttribute": "6", "email": "testpending4@test.cl", "sub": "etc..."}, ... rest of user info data from Cognito}
So, I'm getting some weird output in myAttribute at calling the function, but the real data from Cognito comes later on userInfo
How can I get the real data on myAttribute as well?