I am not able to pull in rest of the data from google sheet using the code below. Only the header pulls in from google sheet. Any tips?
Google sheets has multiple rows and column populated with data.
import {getValuesfromgooglesheet} from 'backend/googlesheets';
$w.onReady(function () {
const populatetable = async ()=>{
const data = await getValuesfromgooglesheet("B1:z10");
const rows = data.data.values;
const headers = rows[0];
let formattedcolumns = [];
headers.forEach((header) => {
const column = {
"id": header,
"dataPath": header,
"label": header,
"width": 100,
"visible": true,
"type":"string",
}
formattedcolumns.push(column);
})
let formattedRows = [];
for(let i = 0; i < rows.lenght; i++){
const row = {
};
for(let j = 0; j < headers.lenght; j++){
row[headers[j]] = rows[i][j]
}
formattedRows.push(row);
}
$w("#googlesheetable").columns = formattedcolumns;
$w("#googlesheetable").rows = formattedRows;
}
populatetable();
});
Looks like you have a typo in the word length :)