I tried to upload a file to my API using React Typescript, but I can't get the FormData parameters right.
My states defined as this (I use observable here):
And here is my upload action:
Thanks!!
CodePudding user response:
The FormData.append() method accepts...
a
USVString
orBlob
(including subclasses such asFile
)
Your PipelineStore
has a nullable FileList in its file
property. Either add files by index or iterate the list
//add by index
formData.append("asda", this.file![0]);
// or iterate
for (const f of this.file!) {
formData.append("asda", f);
}