object-to-formdata icon indicating copy to clipboard operation
object-to-formdata copied to clipboard

Not supported the nested objects

Open IslamicProgrammer opened this issue 2 years ago • 4 comments

I have tried to convert the nested object to formData with serialize

let object = { key1: "VALUE1", key2: { nestedKey1: "NESTED_VALUE1" } }

but it is not support this case ==(

IslamicProgrammer avatar May 06 '22 11:05 IslamicProgrammer

Can you provide a more thorough code example? The tests are passing for this case.

therealparmesh avatar Aug 07 '22 22:08 therealparmesh

I have the same issue.

The library doesn’t allow to send nested objects. For example, instead of { data: { user: 1 } } it sends { data[user]: 1 } where 'data[user]' is a solid string key.

The same for files, backend (KoaJS) have to do dirty hacks like files['documents[]']

Also, it doesn’t allow to send boolean values. Instead of real true or false, it sends strings, e.g. 'true'.

I use 4.4.2 version.

lutaev-georgia avatar Aug 10 '22 12:08 lutaev-georgia

Looks like you had the same issues, for example https://github.com/therealparmesh/object-to-formdata/issues/187

lutaev-georgia avatar Aug 10 '22 12:08 lutaev-georgia

Also, it doesn’t allow to send boolean values. Instead of real true or false, it sends strings, e.g. 'true'.

That's because FormData values can only be strings or Blobs. https://developer.mozilla.org/en-US/docs/Web/API/FormData/append

joemaffei avatar Sep 07 '22 15:09 joemaffei

Thank you a lot

IslamicProgrammer avatar Nov 12 '22 22:11 IslamicProgrammer