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
TypeScript
"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);
});```
TL;DR
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.I highly suggest you do some research or tutorials on promises to understand how they work and how to use them
I solved my error, thanks🫡
Recommended threads
- Use queries on relationships other than ...
Can I use queries other than Query.select on relationships such as Query.equal('relationship.someattr', 'value')?
- Invalid query: Attribute not found in sc...
Hiya. I'm trying to use the REST API with documents and doing a simple select with query: https://<mydomain>/v1/databases/<database>/collections/<collection>/d...
- Hosted a webite on appwrite 2 days ago, ...
I dont really know why its down, everything looks fine, the deployments and all