Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

151
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda