Array from JS to App Connect

Looks to me some code is missing here. Don't you do anything like:

records.push(record);

inside the forEach, which is missing from the code you pasted?
Anyway here it's explained how to access js values from App Connect: