首页 > 解决方案 > 为什么我的 AWS-Amplify 注册请求不包含某些参数?

问题描述

为什么我的 Vuejs 应用程序中的 AWS Amplify 注册请求不包含指定参数?

我正在调用 AWS Amplify 库中描述的 signUp 方法...

/**
 * 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>;

这是我调用signUp方法的包装方法......

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,
      })
    })
}

通过控制台日志语句,我确认我正在将正确的变量传递给包装器方法。例如...

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

这是我得到的错误。

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

标签: vue.jsauthenticationamazon-cognitoaws-amplifyaws-userpools

解决方案


尝试像这样调用函数:

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

推荐阅读