jimmywarting / FormData

HTML5 `FormData` polyfill for Browsers and nodejs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

treat underlying data as an array

jimmywarting opened this issue · comments

We treat the data as an object

{
  key1: [value1, value2, ...]
  key2: [value1, value2, ...]
}

while really it should be an array.

[
  [key1, value1],
  [key1, value2],
  [key2, value1],
  [key2, value2]
]

the order they were added should be the order they should appear in the body as well.
calling .keys() should return [key1, key1, key2, key2] not [key1, key2]

const fd = new FormData()
fd.append('a', 'a1')
fd.append('b', 'b1')
fd.append('a', 'a2')
fd.append('b', 'b2')

console.log(...fd.keys()) // [a,b,a,b]
console.log(...fd.values()) // [a1,b1,a2,b2]