作者:用户hxjr5k4y3f | 来源:互联网 | 2022-11-29 18:33
1> thomasmichae..:
这里的问题是您正在使用异步lambda,但未返回任何可等待的内容。这意味着您的lambda将在docClient.put
发送操作之前终止。
使用异步处理程序,您需要等待并返回,例如,您可以将此代码段更改为:
const data = await docClient.put(params).promise();
return data;
或者相反,您可以使用此callback
方法(请注意,处理程序的签名已不再包含async
):
exports.handler = (event, context, callback) => {
// ... the rest of the code as was ...
docClient.put(params, function(err, data) {
if (err) {
console.log(err);
callback(err); // return 'lambda invoke failed because of the error' - will cause s3 to retry three times.
} else {
console.log(data);
callback(null, data); // return 'nothing failed'; n.b. the s3 trigger ignores whatever you return.
}
});
};