1. 20
    Adding data to a DynamoDB table with put operation
    2m 41s

Adding data to a DynamoDB table with put operation

InstructorTomasz Łakomy

Share this video with your friends

Send Tweet

In this quick lesson we're going to expand our todoHandler.ts lambda function in order to implement a addTodoItem method with AWS.DynamoDB.DocumentClient put operation

Matt
~ 4 years ago

When testing the api in insomnia or postman with a put request, my response is 500 error "todo is missing" even though it successfully adds the item to the database.

When I mouse over the 'todo' in the return statement in:

if (httpMethod === "POST") { const todo = await addTodoItem(data); return todo ? createResponse(${todo} added to the database) : createResponse("Todo is missing", 500); }

I'm getting a warning in my editor (VScode) that "an expression of type 'void' cannot be tested for truthiness". I suspect that's the cause however I'm not sure how to fix it. I'll update if I find a solution.

Matt
~ 4 years ago

I was missing the last "return todo;" statement in the addTodoItem function. Makes sense it couldn't be evaluated.

Tunca Tunc
~ 4 years ago

todoHandler.handler lambda function cannot be found when invoked It only worked after I compiled with tsc and todoHandler.js is generated.