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
- Not allowed permission to upsert a prese...
```js const presenceID = ID.unique(); setPID(presenceID); const presence = await presences.upsert({ presenceId: presenceID, status: "online"...
- Finding job
Hi. I am a full-stack developer with experience in developing scalable and user-friendly web applications. I handle both front-end and back-end development, im...
- CDN not delivering correct bundle
My site 69b4cd410035893573dc is not delivering the latest deployed version via CDN, it seems stuck on versions from previoiu days, alternative links for the lat...