Can't update through API


#1

I am not familiar with Ajax and this may seem like a silly question but

according to the documents

Create / Update collection entries

fetch('/api/collections/save/posts?token=xxtokenxx', {
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
        data: {...}
    })
})
.then(res=>res.json())
.then(entry => console.log(entry));

I can insert new entries but I cannot update any of my entries.
would you please give me an example to how I can update an existing entry ?


#2

@Hypothesis-github
An update is triggered when your data structure contains a valid _id, are you passing the entry _id in the request? For me below works well:


#3

Thanks dude, I got it working with you mentioning the “_id”