【问题标题】:AWS amplify TruncatingBigNumber can not be converted to an StringAWS amplify TruncateBigNumber 无法转换为字符串
【发布时间】:2020-09-06 10:33:50
【问题描述】:

所以,我尝试使用 amplify 中的 forgotPasswordSubmit 重置密码,我将先前询问的安全代码作为参数传递,该安全代码发送到电子邮件和两次新密码,当我发送值时,我在控制台:

ERROR Error: Uncaught (in promise): Object: {"code":"SerializationException","name":"SerializationException","message":"class com.amazon.coral.value.json.numbers.TruncatingBigNumber can not be converted to an String"}
    at resolvePromise (zone-evergreen.js:798)
    at resolvePromise (zone-evergreen.js:750)
    at zone-evergreen.js:860
    at ZoneDelegate.invokeTask (zone-evergreen.js:399)
    at Object.onInvokeTask (core.js:41264)
    at ZoneDelegate.invokeTask (zone-evergreen.js:398)
    at Zone.runTask (zone-evergreen.js:167)
    at drainMicroTaskQueue (zone-evergreen.js:569)

这是我的html代码:

<div *ngIf="newPassword">
 <form  [formGroup]="passwordForm"(ngSubmit)="verifyPassword(passwordForm.value)">
  <class="form-group">
   <label for="">Código</label>
   <input type="number" class="form-control" id="exampleInputverifycode1"  #verifycode formControlName = "code" placeholder="Ingresa el código">
   </div>
   <div>
    <label for="">Contraseña</label>
    <input type="password" name="password" id="exampleInputverifycode1"  #verifycode formControlName = "password" placeholder="Ingresa tu contraseña">
   </div>
   <div>
    <label for="">Contraseña</label>
    <input type="password" name="password" id="exampleInputverifycode1"  #verifycode formControlName = "passwordRepeat" placeholder="vuelve a escribir tu contraseña">
   </div>
   <div class="modal-footer">
    <button role="button" class="btn btn-forms-submit w-100" >Aceptar</button> 
   </div>
</form>

这是验证通过表单给出的值的代码:

    passwordForm = new FormGroup({
     code: new FormControl('', [Validators.required]),
   password: new FormControl('',[Validators.required]),
     passwordRepeat: new FormControl('',[Validators.required])
   })
    verifyPassword(value){
     console.log(value);
     Auth.forgotPasswordSubmit(value.code,value.password, value.passwordRepeat)
      .then(data=> console.log(data)
      )
    }

【问题讨论】:

  • 看起来您的同一个 id (exampleInputverifycode1) 被使用了 3 次,可能值得确保这不是复合问题。

标签: angular amazon-web-services amazon-cognito aws-amplify


【解决方案1】:

尝试将您的数字字段更改为安全代码的文本(在您的示例中为exampleInputverifycode1)。在将 aws-amplify 中的 verifyTotpToken 方法与 Formik 库一起使用时,我看到了同样的问题,this issue 指出了一个解决方案。如果您尝试像我第一次尝试的那样尝试将数字转换为从表格开始的更下方的字符串,则可能是例如000123 将被解释为 123 导致不同类型的错误。总之,请确保您的表单发送的是字符串而不是整数。

【讨论】:

    猜你喜欢
    • 2020-07-20
    • 1970-01-01
    • 2022-01-13
    • 2012-09-19
    • 1970-01-01
    • 1970-01-01
    • 2021-11-15
    • 2018-02-19
    • 2012-01-07
    相关资源
    最近更新 更多