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

346
Views
La recuperación de NodeJS falló (el objeto 2 no es iterable) al cargar el archivo a través de la solicitud POST

Estoy tratando de cargar un archivo usando la búsqueda nativa en NodeJS (agregado en el nodo 17.5, consulte https://nodejs.org/ko/blog/release/v17.5.0/ ).

Sin embargo, sigo recibiendo el siguiente error:

 TypeError: fetch failed at Object.processResponse (node:internal/deps/undici/undici:5536:34) at node:internal/deps/undici/undici:5858:42 at node:internal/process/task_queues:140:7 at AsyncResource.runInAsyncScope (node:async_hooks:202:9) at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { cause: TypeError: object2 is not iterable at action (node:internal/deps/undici/undici:1660:39) at action.next (<anonymous>) at Object.pull (node:internal/deps/undici/undici:1708:52) at ensureIsPromise (node:internal/webstreams/util:172:19) at readableStreamDefaultControllerCallPullIfNeeded node:internal/webstreams/readablestream:1884:5) at node:internal/webstreams/readablestream:1974:7 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Estoy usando el siguiente código para crear y enviar la respuesta del formulario:

 function upload(hub_entity_id, document_path) { let formData = new FormData(); formData.append("type", "Document"); formData.append("name", "ap_test_document.pdf"); formData.append("file", fs.createReadStream("ap_test_document.pdf")); formData.append("entity_object_id", hub_entity_id); const form_headers = { Authorization: auth_code, ...formData.getHeaders(), }; console.log( `Uploading document ap_test_document.pdf to hub (${hub_entity_id}) ` ); console.log(formData); let raw_response = await fetch(urls.attachments, { method: "POST", headers: form_headers, body: formData, }); console.log(raw_response); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Use fs.readFileSync en lugar de createReadStream

formData.append("archivo", fs.readFileSync("ap_test_document.pdf"));

También puede usar el nombre de archivo directamente en formData.append

formData.append("archivo", fs.readFileSync("ap_test_document.pdf"), "ap_test_document.pdf");

about 4 years ago · Juan Pablo Isaza 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!