fix: multipart form data sorting (#2067)

* fix: multipart form data sorting

  place all the file types in multipart form data
  body in the last to avoid errors due to map key
  being placed after file type data

* refactor: fp-ify formdata file sort implementation

Co-authored-by: Liyas Thomas <liyascthomas@gmail.com>
Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
This commit is contained in:
kyteinsky
2022-01-22 21:00:39 +00:00
committed by GitHub
parent 3bb65f2115
commit 6205b5f163
3 changed files with 83 additions and 19 deletions

View File

@@ -0,0 +1,12 @@
type FormDataEntry = {
key: string
value: string | Blob
}
export const toFormData = (values: FormDataEntry[]) => {
const formData = new FormData()
values.forEach(({ key, value }) => formData.append(key, value))
return formData
}