[英]Create the DynamoDB global Table if doesn't exist using Cloudformation
[英]Lambda doesn't create data in DynamoDB
我收到代碼響應 200 成功
但 null json 消息 Postman
數據不是在 DynamoDB 中創建的。 這是我的 lambda:
exports.handler = async (event, context, callback) => { const id = replaceAll(event.queryStringParameters.authorId, " ", "-").toLowerCase(); const params = { Item: { id: { S: id }, title: { S: event.queryStringParameters.title }, watchHref: { S: event.queryStringParameters.watchHref }, authorId: { S: event.queryStringParameters.authorId }, length: { S: event.queryStringParameters.length }, category: { S: event.queryStringParameters.category } }, TableName: "todos" }; // console.log("@@@@@@@@@@@ ID " + params.Item.id.S + ""); // console.log("@@@@@@@@@@@ Title " + params.Item.title.S + ""); // console.log("@@@@@@@@@@@ Title " + params.Item.watchHref.S + ""); // console.log("@@@@@@@@@@@ Title " + params.Item.authorId.S + ""); // console.log("@@@@@@@@@@@ Title " + params.Item.length.S + ""); // console.log("@@@@@@@@@@@ Title " + params.Item.category.S + ""); dynamodb.putItem(params, function (err, data) { console.log("@@@@@@@@@@@ ID " + params.Item.id.S + ""); if (err) { console.log("@@@@@@@@@@@ ERROR" + err); callback(err); } else { console.log("@@@@@@@@@@ INSIDE ELSE"); callback(null, { id: params.Item.id.S, title: params.Item.title.S, watchHref: params.Item.watchHref.S, authorId: params.Item.authorId.S, length: params.Item.length.S, category: params.Item.category.S }); } }); };
我究竟做錯了什么? 我遵循與文檔相同的原則。
作為參考,我正在使用 HTTP API 網關代理集成,這是我的表格:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.