Hi guys, I have been trying to display the response I got from a 3rd party API on a table. I used the following to guide me, but I can’t seem to get this example to work. The table remains empty after I run the code.
The example assumes you have a table with ID myTable that contains two fields, name(type Text) and num (type Number).
const myTableData = [
{“name”: “A”, “num”: 45},
{“name”: “B”, “num”: 34},
{“name”: “C”, “num”: 19},
{“name”: “D”, “num”: 59},
{“name”: “E”, “num”: 24},
{“name”: “F”, “num”: 96}
];
$w.onReady(function () {
$w(“#myTable”).dataFetcher = getRows;
});
function getRows(startRow, endRow) {
return new Promise( (resolve, reject) => {
// Fetch the objects from startRow to endRow from myTableData
:
const fetchedDataRows = myTableData.slice(startRow, endRow);
// resolve to DataRequested object
resolve( {
pageRows: fetchedDataRows,
totalRowsCount: myTableData.length
} );
} );
}
from - https://www.wix.com/code/reference/$w.Table.html
Thanks in advance!
A.