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

226
Views
¿Cómo puedo cambiar el valor de FormData() para recibir el valor del cuadro de texto?

Estoy obteniendo datos de una API y colocándolos en una tabla para reaccionar hasta ahora, pero cuando trato de editar los datos de una fila en la tabla. Esto me da el error "PUT 400 (Solicitud incorrecta)". ¿Cómo debo cambiar FormData() para recibir el valor de "<Form.Control/>" y luego recibirlo del backend?

---Editar2.js---

 handlerSubmit = async (event) => { event.preventDefault(); let formData = new FormData(); formData.set("", event.target.legenda.value); let resposta = await fetch("api/FotografiasAPI/" + this.props.idLinha, { method: "PUT", headers:{'Accept':'application/json','Content-Type':'application/json'}, body: formData }); if (!resposta.ok) { console.error("error:" + resposta.status); } return await resposta.json(); } render(){ return( <Modal {...this.props}> <Form onSubmit={this.handlerSubmit}> <Form.Group controlId="legenda"> <Form.Label>legenda</Form.Label> <Form.Control defaultValue = {this.props.legenda} type="text"name="legenda" required placeholder="legenda"/> </Form.Group> <Form.Group> <Button variant="primary" type="submit"> Editar Restaurante </Button> </Form.Group> </Form> </Modal> );}}

---Backend---

 [HttpPut("{id}")] public async Task<IActionResult> PutFotografias(int id, [FromForm] Fotografias fotografias) { if (id != fotografias.ID) {return BadRequest();} _context.Entry(fotografias).State = EntityState.Modified; try {await _context.SaveChangesAsync();} catch (DbUpdateConcurrencyException) { if (!FotografiasExists(id)) {return NotFound();} else {throw;}} return NoContent(); }
about 4 years ago · Juan Pablo Isaza
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!