vue.jsauthenticationamazon-cognitoaws-amplifyaws-userpools

Why does my AWS-Amplify sign up request not include some parameters?


Why do AWS Amplify sign up requests in my Vuejs app not include the specified parameters?

I am calling the signUp method described here in the AWS Amplify library ...

/**
 * Sign up with username, password and other attributes like phone, email
 * @param {String | object} params - The user attributes used for signin
 * @param {String[]} restOfAttrs - for the backward compatability
 * @return - A promise resolves callback data if success
 */
signUp(params: string | SignUpParams, ...restOfAttrs: string[]): Promise<ISignUpResult>;

Here is my wrapper method that calls the signUp method...

export async function register(email, password, username, phone_number) {

  return Auth
    .signUp({ username, password }, email, phone_number)
    .then(data => console.log())
    .catch(error => {
      notification.warning({
        message: error.code,
        description: error.message,
      })
    })
}

With console log statements, I confirmed that I am passing proper variables into the wrapper method. For example...

email: Sally1234@gmail.com, 
password: Sally123!, 
username: Sally1234@gmail.com (yes, this username matches the email - to satisfy another Amplify requirement),
phone_number: +18081124351

Here is the error I am getting.

InvalidParameterException
Attributes did not conform to the schema: name: The attribute is required phone_number: The attribute is required

Solution

  • Try calling the function like this:

    Auth.signUp({ username, password, attributes: { email, phone_number } } );