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

369
Views
Iterate an Object and Append as FormData (Including files, and normal text)

I'm trying to upload files using formData, but also I do have some other fields that I need to include in the formData, so because I have an long object I want a automatic loop that iterates through the object I have and fills the form data.

For example this is my object:

const data {
  name: 'Adrian',
  files: [many other file uploads],
  houses: ['Mansion Q', 'Small Tini Sini House :P']
}

And this is the data I need to stimulate:

const formData = new FormData();
// someway to formData.append('the key', 'value of the key')
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This should help you

const formData = new FormData();
Object.entries(data).forEach(entry => {
    const [key, value] = entry;
    formData.append(key, JSON.stringify(value));
})
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!