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

150
Visualizações
I wanna update a value to request with React axios from Django

This is one of value in Django api.

{
        "id": 89,
        "text": "dd",
         "checked": false
},
{
        "id": 90,
        "text": "dd",
        "checked": false
},

I wanna update the "checked" value like true/false to request with react axios.

Like a check toggle button.

const [check, setCheck] = useState(false);

return (
        <>
            <button onClick = { () => setCheck(!check) }>X</button>
            <div className = {`todo ${check && 'checked'}`}>{ text</div>
        </>
);
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You should be calling an API on checkbox toggle (data sent to server and structure may vary as there is no exact code provided)

  • toggle function gets called on click of each checkbox, from the event we can get the value, and its current state of checked

  • put your API and the data to send correctly (I assumed from the data u put)

import "./styles.css";
import axios from "axios";

export default function App() {
  function toggle(e) {
    axios
      .post("/put-your-api-here", {
        id: e.target.value,
        text: e.target.value,
        checked: e.target.checked
      })
      .then(function (response) {
        console.log(response);
      })
      .catch(function (error) {
        console.log(error);
      });
  }
  return (
    <div className="App">
      {[1, 2, 3, 4, 5, 6, 7, 8].map((el) => (
        <>
          <input type="checkbox" onClick={toggle} value={el}></input>
          {el}
          {"  "}
        </>
      ))}
    </div>
  );
}

about 4 years ago · Santiago Trujillo Relatório
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