An Amazon Cognito user pool is a user directory for your web, mobile or other applications. In addition to the normal things you expect to store in an Amazon Cognito user pool (such as a user name, e-mail address or phone number), you can also configure the user pool to store other desired information via custom attributes. With the latest AWS Amplify release, we've added the ability to store and retrieve custom attributes in your Amazon Cognito user group.
When this function could be useful Imagine that you are building an application for an ice cream parlor. In your customer database, you want to make sure that you know the favorite ice type of each user. When a new customer registers, you can ask him for this information and add it to his profile. From then on, their favorite ice type would be easily accessible, along with the rest of their user profile!
If you want to create a custom attribute during registration, add this to the characteristic field of the signup -method from the Auth class :
You can call Auth.currentUserInfo () to retrieve the profile of the user, which contains all attributes. For example to access the user's favorite ice cream flavor in your web or mobile app:
Try catch (err)
You can also update a custom attribute. Use the method Auth.updateUserAttributes () :
const result = wait for Auth.updateUserAttributes (user, );
For more information about AWS Amplify, see the documentation for the developer.