0

I am trying to append an array of objects through form data. But it's not working as I expected. This is my Array ob object.

const children = [{title:"MacBook",type:"LapTop"},{title:"MSI",type:"LapTop"}]

This is how I append my data to formData.

const formData = new FormData();
children.forEach(item => {
            formData.append('children[]', item)
        });

But this is how the final output. enter image description here

I tried this using JSON.stringify() to serialize.But it's not working. anyone can help me with this..?

What I expect to like this: enter image description here

4
  • What is your expected result and what is wrong with the output you're getting? Have you seen: JS, how to append array in FormData? Aug 14, 2022 at 13:45
  • share a snack with your code and let us know what's your expected output Aug 14, 2022 at 13:46
  • @Nick Parsons I update my question. Can you help me now..?
    – Zenixo
    Aug 14, 2022 at 14:13
  • @Salwa A. Soliman I update my question. Can you help me now..?
    – Zenixo
    Aug 14, 2022 at 14:13

0