I have a fairly simple call to my code.gs file for some data that lives in a sheet. I am calling this function from a html file to populate a drop down list. So:
Code.gs
function getTheStuffINeed() {
// Get data from sheet
var ss = SpreadsheetApp.openById("ss_id");
var sheet = ss.getSheetByName("sheetname");
var myStuff = sheet.getRange(2, 1, sheet.getLastRow()-1, 3).getValues();
Logger.log(Array.isArray(myStuff)); // true.
Logger.log(myStuff); // [[id1, aVal, aSecondVal], [id2, AnotherVal, anotherSecondVal]]
return myStuff ; // An array of arrays
}
index.html
<script>
// get data
var myStuff= <?= getTheStuffINeed() ?>;
console.log(Array.isArray(myStuff)); // false
console.log(myStuff); // id1, aVal, aSecondVal, id2, AnotherVal, anotherSecondVal, etc
</script>
When my result hits the html page it is no longer an array of arrays, rather a single string of comma separated values.
Can someone please explain what is happening here, and how to fix? Thank you.