I've got an issue here with formatting my json and I can't quite figure out how to do it. when I run this code via Lambda:
let body;
let statusCode = 200;
const headers = {
"Content-Type": "application/json"
};
body = await dynamo.scan({ TableName: "MyTutorials" }).promise();
body = JSON.stringify(body);
It returns as json string that looks like this:
{
"Items": [
{
"published": false,
"description": "This is an orange.",
"id": 2,
"title": "Orange"
},
{
"published": true,
"description": "this is an apple",
"id": 1,
"title": "Apple"
}
],
"Count": 2,
"ScannedCount": 2
}
Thats great and all, but for my React app I need something cleaner that looks like this:
[
{
"published": false,
"description": "This is an orange.",
"id": 2,
"title": "Orange"
},
{
"published": true,
"description": "this is an apple",
"id": 1,
"title": "Apple"
}
]
Bascially, I need just the straight-up array in the json and not wrapped with all the other stuff like "Items" and "Count." Any ideas on how to make that call?