I am trying to implement a feature where the stock of a product goes down. Right now I do this using a button. The problem now lies with how I do this. I am using strapi as my CMS and want to update a value called "stock" whenever I click the button. The PUT request seems to work fine and strapi indicates the product has been updated. But the value I passed through didn't get changed.
Here is my code
const handlePut = () => {
axios.get('https://strapi.***.com/api/kledings/1').then(res => {
let obj = res.data
obj.data.attributes.stock -= 1
axios.put('https://strapi.***.com/api/kledings/1', obj).then(res => {
console.log(res.data, 'updated');
})
})
}
Strapi's response to this put request is received with status 200:
My initial stock was 10 and by using handlePut() it should be 9 now. Instead my strapi dashboard shows the following:

So it does show that it has been updated but no values are changes. Does anyone know what I am currently missing?