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

188
Views
Archivos cargados enviados vacíos en reaccionar

Tengo una entrada de tipo de archivo para adjuntar archivos en un formulario. Esta pregunta se hizo antes de que los archivos cargados se enviaran vacíos y la respuesta es envolver los archivos en un formData.

La diferencia en mis códigos es que estos archivos no se envían únicamente, sino como parte de un objeto anidado a través de una solicitud PUT (las acciones se manejan en un reductor)

 export default function checklistVersionReducer(configObj, action) { switch (action.type) { case "initiate": { const { payload } = action; const idAssignedConfig = assignSectionId(payload.config); return { ...payload, config: idAssignedConfig }; } case "update": { const { value, secId, subsecId, item } = action; let configCopy = Object.assign({}, configObj); configCopy.config[secId].subSections[subsecId][item] = value; return configCopy; } /////////////// - Action to handle the attached files - /////////////// case "attach": { const { files, secId, subsecId } = action; const filesData = new FormData(); for (let i = 0; i < files.length; i++) { filesData.append("file", files[i]); } let configCopy = Object.assign({}, configObj); configCopy.config[secId].subSections[subsecId].docs = [filesData]; return configCopy; } /////////////// -/ Action to handle the attached files - /////////////// case "changeStatus": { const { status } = action; return { ...configObj, documentStatus: status }; } case "updateOperator": { const { newOpId } = action; return { ...configObj, operatorId: newOpId }; } case "updateSecondOperator": { const { newOpId } = action; return { ...configObj, operatorId2: newOpId }; } default: console.error("Unhandled action type " + action.type); break; } }

El problema es que todavía envía formData vacíos y no estoy seguro de dónde está el problema.

Cualquier ayuda es apreciada.

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!