AWS Textract - run through data and get values?

So far I’ve been using this post:

To try to get the specific data using a function and create JSON.

Original:

Transform Node from above Workflow:

let result = [];

$json.response.forEach(row => {
    row.stores.forEach(e => {
        result.push({
            json: {
                id: row.id,
                name: e.name,
                type: e.type,
            },
        });
    });
});

return result;

My version:

My transform node:

let result = [];

$json.response.forEach(row => {
row.ExpenseDocuments.SummaryFields.forEach(e => {
        result.push({
            json: {
                name: e.LabelDetection.Text,
                type: e.ValueDetection.Text
            },
        });
    });
});

return result;

However I get:

“Cannot read property ‘forEach’ of undefined [Line 4]”

I have also tried:

let result = [];

$json.response.forEach(row => {
row.ExpenseDocuments.forEach(e => {
        result.push({
            json: {
                name: e.SummaryFields.LabelDetection.Text,
                type: e.SummaryFields.ValueDetection.Text
            },
        });
    });
});

return result;

Not sure what I’m doing wrong :confused: