cognitoUser.getAttributeVerificationCode 抛出错误“无效的 lambda 函数输出:无效的 JSON”

JSn*_*now 5 javascript node.js amazon-cognito aws-lambda

我一直在尝试使用 Amazon Cognito 中的 getAttributeVerificationCode Api 验证用户电子邮件。这是我的代码。

cognitoUser.getAttributeVerificationCode('email', {
onSuccess: function (result) {
  // console.log("type",typeof params.AttributeName);
  console.log('call result: ' + result)
  response = {
    statusCode: 200,
    body: JSON.stringify({ message: 'onSuccess' }),
    headers: {
      'Content-Type': 'application/json'
    }
  }
  callback(null, response)
},
onFailure: function (err) {
  // console.log(err)
  response = {
    statusCode: 200,
    body: JSON.stringify({ message: err.message }),
    headers: {
      'Content-Type': 'application/json'
    }
  }
  callback(null, response)
},
inputVerificationCode: function () {
  // var verificationCode = prompt('Please input verification code: ' ,'');
  // cognitoUser.verifyAttribute('email', verificationCode, this);
  console.log('verification code')
}
Run Code Online (Sandbox Code Playgroud)

})

这会显示错误“无效的 lambda 函数输出:无效的 JSON”。任何帮助将不胜感激。