I am trying to add another property to each object I receive from the DynamoDB table. I am trying to do this by altering each object in the Items array then adding the Items array to my responseBody. All I get in return is the original items without any new properties. This could be a product of me using the array functions or spread operator incorrectly, just kindly point out anything you may see. My lambda function is below:
const data = await documentClient.scan(params).promise();
data.Items.map(item => {
item = {
...item,
control: control_id
};
});
responseBody = JSON.stringify(data.Items);
UPDATE: I solved my issue above by doing the following:
const data = await documentClient.scan(params).promise();
data.Items.forEach(item => {
item.control = control_id;
});
responseBody = JSON.stringify(data);