I am facing issues with sending file data to POST API.
Here is the code I am using →
Here Fetch is from bs-fetch library
// CkycFormData file
type t = Fetch.formData
@new external make: unit => t = “FormData”
@send external append: (t, string, string) => unit = “append”
@send external access: (t, string) => string = “get”
// main file
type target = {
value: string,
checked: bool,
files: array,
}
external target: {…} => target = “%identity”
let target = (event): target => event->ReactEvent.Form.target->target
let myFile = (event->target).files[0]
let formData = CkycFormData.make()
CkycFormData.append(formData, “file”, myFile)
Then I am passing this formData in body of API.
The problem is in the API request payload I see this →
------WebKitFormBoundaryBS5aPvaLJSqwt3zi
Content-Disposition: form-data; name=“file”; filename=“500829-Anime-Demon-Slayer-Kimetsu-no-Yaiba-Nezuko-Kamado.jpg”
Content-Type: image/jpeg
The file data is not coming up.
I need help in debugging why the file data is not coming up in the request