I am trying to return the result of a URLFetchApp API fetch in Google App Script back into Google Sheets using 'sheet.getRange().setValues()'. I can populate individual cells from a variable with one value using the 'setValue()' version however I am stuck when trying to populate multiple cells from an array.
If I 'log(arr)' my variable looks like this,
[19-10-12 15:17:45:538 BST] [99]
[19-10-12 15:17:45:669 BST] [98.9]
[19-10-12 15:17:45:829 BST] [91]
[19-10-12 15:17:45:970 BST] [96.4]
[19-10-12 15:17:46:298 BST] [91.6]
[19-10-12 15:17:46:441 BST] [110.6]
[19-10-12 15:17:46:600 BST] [93.7]
[19-10-12 15:17:46:762 BST] [93.8]
[19-10-12 15:17:46:903 BST] [92.6]
I think it should be like this
[99,98.9,91,96.4,91.6,110.6,93.7,93.8,92.6]
There are lots of detailed guides on using the concat() function to merge variables into one array but I cant find any info how to deal with the incorrect way I have it mapped.
The result is the error TypeError: Cannot read property "length" from undefined. which must be due to my improperly formatted array.
Any help greatly appreciated feel like a right potato at the mo.
var records = results.map(function (positions){
var position = positions.Metrics.Position;
var arr = [];
arr.push(position);
sheet.getRange(6,3,arr.length,arr[0].length).setValues(arr);
Logger.log(arr)