A real shipping form at the counter: new FormData(form), get vs getAll, then fetch to the gudang as multipart or urlencoded. An interactive FormData…
Why it matters
Every form sent to a server goes this way. Collecting values with querySelector one by one misses things; FormData reads them all, checkbox groups and files included, and fetch writes the right Content-Type itself.
The key idea
FormData reads the form as it is, repeated names included
Common mistakes
Reading a checkbox group with .get()get('barang') gives only the FIRST. For everything ticked, use getAll('barang'): an array.
Writing the Content-Type yourself for FormData Do not. The browser writes multipart/form-data with its boundary. Written by hand, the boundary is gone and the server cannot read it (400).
Thinking a control without a name is sent FormData and a native submit read only controls with a name. Forget the name and your field silently disappears.
Try it in this playground
fd.getAll('barang') on three ticks One entry per tick, the same name.
fd.get('barang') gives only the first Situation 1: of three ticks, get() gives one.
Give the note a name Situation 2: without a name, a field is never read.
Send with a hand-written Content-Type Situation 3: with no boundary, the gudang answers 400.