examples
examples copied to clipboard
The DynamoDB / PutItemCommand example returns undefined
- File: aws-dynamodb/pages/api/item.js
- Row: 28
return res.status(201).json(Item);
Returns undefined
even on a successful insert
Is the issue from Item
? I believe it was working when I tested. Any more information?
Hi Lee
Yes, the PutItemCommand does not return the item's attribute values in the same operation, one has to use the ReturnValues parameter to do so. For this reasons Item
in { Item }
is undefined
.
And by the looks of it, for PutItem you only have the option of ALL_OLD
for a ReturnValues param ... where if you write a nonexistent item (ie. create a new record), ALL_OLD has no effect.
My workaround (like your earlier cdk v2 version) is to create the Item object before, and pass it into the PutItemCommand, and on successful insert, return the Item object.
Regards, H.