Displaying data onto a table

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.

Ayub, though it looks like you paid attention to case sensitivity, I thought I’d say this anyway. I could get it to not bring the data in if I enter the field names for the columns as Name and Num. When the fields are lower case like they should be, it displays the data.

Hi Anthony, Thank you for your reply.
That actually solved my problem :slight_smile:
A.

Well, I Would like an example of how to do this with Query instead of with a constant table. I’m trying to do that and not getting it

Perhaps you should better open an own new post with a detailed question related to your own issue, instead of pushing an old post.