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

183
Views
Espere a que el archivo se descargue por completo antes de descargar el siguiente

Tengo un área para cargar archivos, con la capacidad de arrastrar y soltar varios archivos, al cargar, necesito agregar la posición de cada archivo a la solicitud ( filePosition ). La posición del archivo es la longitud de la matriz que se completa después de cargar los archivos. La pregunta es cómo hacer que la próxima llamada de búsqueda se ejecute solo después de que el objeto de archivo se agregue a la matriz.

 let materialFiles: [{ lang: 'en', files: { restFiles: [] } }, ], let files = e.target.files || e.dataTransfer.files; let allowFiles = this.validateFiles(e, files, curObj); Array.from(allowFiles).forEach(file => { attachThumbnail(curObj, file, e.target) }); async attachThumbnail(curObj, file, eventTarget) { let index = this.formData.materialFiles.findIndex(item => item.lang === curObj.lang); let filePosition = curObj.files.restFiles.length; this.uploadFile(curObj, file, 'rest', filePosition) .then(response => response.json()) .then(data => { this.formData.materialFiles[index].files.restFiles.push({ name: data.fileName, id: data.id }) }) .catch(error => { console.log(error) }); }, uploadFile(curObj, file, type, position) { let formData = new FormData(), data = { document: file, type: type, lang: curObj.lang, position: type === 'rest' ? position : 0 } for (let key in data) { formData.append(key, data[key]); } fetch('/api/material_media', { method: 'POST', body: formData, }) },

En mi caso, la búsqueda se realiza primero y solo luego se produce la inserción. Es necesario que primero vaya a luego y agregue un objeto a la matriz (para que su longitud cambie) y luego se llama a buscar para el siguiente archivo.

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!