Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

197
Visualizações
Strapi put request using Axios

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:

enter image description here

My initial stock was 10 and by using handlePut() it should be 9 now. Instead my strapi dashboard shows the following: enter image description here

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

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda