Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services AWS无法识别的Lambda输出Cognito错误_Amazon Web Services_Triggers_Amazon Cognito - Fatal编程技术网

Amazon web services AWS无法识别的Lambda输出Cognito错误

Amazon web services AWS无法识别的Lambda输出Cognito错误,amazon-web-services,triggers,amazon-cognito,Amazon Web Services,Triggers,Amazon Cognito,我最近开始与AWS合作。我已经使用cognito用户池集成了AWS Amplify,用于我的用户管理(登录和注册),它非常完美(每当新用户注册时,用户池都会更新)。现在,我添加了一个Cognito Post确认触发器来将注册的电子邮件保存到数据库中,下面是我的触发器codevar mysql=require('mysql') 每当用户注册并确认其电子邮件时,此触发器就会调用并向我抛出此错误 “无法识别的Lambda输出Cognito”。尽管它在后台向我抛出了这个错误,我的数据库将被插入新的注册电

我最近开始与AWS合作。我已经使用cognito用户池集成了AWS Amplify,用于我的用户管理(登录和注册),它非常完美(每当新用户注册时,用户池都会更新)。现在,我添加了一个Cognito Post确认触发器来将注册的电子邮件保存到数据库中,下面是我的触发器codevar mysql=require('mysql')

每当用户注册并确认其电子邮件时,此触发器就会调用并向我抛出此错误 “无法识别的Lambda输出Cognito”。尽管它在后台向我抛出了这个错误,我的数据库将被插入新的注册电子邮件,但我无法重定向我的页面,因为这一点。任何帮助都将不胜感激。谢谢


Aravind

简短回答:替换
回调(空,结果)
回调(空,事件)

原因:您必须返回Cognito将使用它继续验证工作流的结果。在本例中,这是
事件
对象

var config = require('./config.json');

var pool = mysql.createPool({

host : config.dbhost,

user : config.dbuser,

password : config.dbpassword,

database : config.dbname

});

exports.handler = (event, context, callback) => {

let inserts = [event.request.userAttributes.email];

context.callbackWaitsForEmptyEventLoop = false; //prevents duplicate entry

pool.getConnection(function(error, connection) {

connection.query({

sql: 'INSERT INTO users (Email) VALUES (?);',

timeout: 40000, // 40s

values: inserts

}, function (error, results, fields) {

// And done with the connection.

connection.release();

// Handle error after the release.

if (error) callback(error);

else callback(null, results);

});

});

};