I am trying to update a document which has an array attribute called Upvotes This is where it stores all the users that have upvoted the doc. and I am using this function the handle it.
function upvote(docID: any) {
const promise = appwriteDatabases.updateDocument(DatabaseID,CollectionID,DocumentID,{
'Name': docID.Name,
'Tagline': docID.Tagline,
'Description': docID.Description,
'Link': docID.Link,
'Free': docID.Free,
'LaunchDate': docID.LaunchDate,
'Author': docID.Author,
'Icon': docID.Icon,
'Thumbnail': docID.Thumbnail,
'Authoruid': docID.Authoruid,
// add the user's uid to the Upvotes array
'Upvotes': [...docID.Upvotes, uid]
});
promise.then((response) => {
console.log(response);
console.log(docID)
}, (error) => {
console.log(error);
alert(error.message);
});
}
The error:
UpvoteBtn.2e957bcf.js:1 Uncaught TypeError: e.Upvotes is not iterable
at h (upvoteBtn.2e957bcf.js:1:778)
at HTMLButtonElement.m (upvoteBtn.2e957bcf.js:1:934)
h
Help appreciated!
Can you log and share the value in docId.Upvotes?
Maybe your Upvotes is empty?
the Upvotes array is empty
Recommended threads
- Usage of the new Client() and dealing wi...
Hey guys, just a quick one - we had some web traffic the other day and it ended up bombing out - To put in perspective of how the app works, we have a Nuxt Ap...
- CORS errors in Obsidian custom plugin
Hi, anyone here familiar with obsidian community plugins? In short: it's a local first note app which supports writing your own add-ons / plugin But I keep get...
- > AppwriteException: The requested servi...
When trying to read or write from my database I get the following error: > AppwriteException: The requested service is disabled. You can enable the service from...