On Cloudwatch I'm having an error that says:
HTTP/1.1" 500 35 ZHTFXgWBoAYEQ4a= The Lambda function returned the following error: "Unhandled". Check your Lambda function code and try again.
I'm trying to build the new HTTP API Gateway with a simple lambda function.
This is my lambda function:
const AWS = require("aws-sdk");
const dynamodb = new AWS.DynamoDB({
region: "us-east-1",
apiVersion: "2012-08-10"
});
exports.handler = (event, context, callback) => {
const params = {
Key: {
id: {
S: event.id
}
},
TableName: "todos"
};
dynamodb.getItem(params, (err, data) => {
if (err) {
console.log(err);
callback(err);
} else {
callback(null, {
id: data.Item.id.S,
title: data.Item.title.S,
watchHref: data.Item.watchHref.S,
authorId: data.Item.authorId.S,
length: data.Item.length.S,
category: data.Item.category.S
});
}
});
};
This is how the data is structured:
This is how I'm invoking it and the JSON response I get:
What am I doing wrong?
EDIT: Here's a more detailed log:
"ValidationException: Supplied AttributeValue is empty, must contain exactly one of the supported datatypes",
But I'm giving it the right values, or not?