mitsy0_0Original post
Rank 2: Process
I'm following the docs,
https://appwrite.io/docs/pagination#cursor-pagination, so do I need to write the code again and again for each page?
And I'm getting an error saying Cannot read properties of undefined (reading 'length')
this is my function
Plain text
"647ac763cf53edxxxxx", "647ac820ba3852xxxxx", [ Query.orderDesc("age"), Query.notEqual("age", ["invalid"]), Query.limit(25) ] ); const lastId = page1.documents[page1.documents.length - 1].$id;
// Page 2 const page2 = databases.listDocuments( '647ac763cf53edxxxxx', '647ac820ba3852xxxxx', [ Query.limit(25), Query.cursorAfter(lastId), ] );
page1.then(function (response) { console.log(response.documents); var tableHTML = generateTable(response.documents); var tableContainer = document.getElementById('tableContainer'); tableContainer.innerHTML = tableHTML; }, function (error) { console.log(error); }); page2.then(function (response) { console.log(response.documents); var tableHTML = generateTable(response.documents); var tableContainer = document.getElementById('tableContainer'); tableContainer.innerHTML = tableHTML; }, function (error) { console.log(error); });```Summary
The user was encountering an error with cursor pagination implementation. They followed the appwrite.io documentation but received an error saying 'Cannot read properties of undefined (reading 'length')'. They included the code they were using for pagination. The user then stated that they have solved the error. There is no further information provided on how they resolved it.