Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

149
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!