Hi i want to send a form to my endpoint Profile, my problem is in the field user:{}, because i can\'t find the way to put my array into this field.
this are the fiel
FormData's append() method can only accept objects of string or blob type. If you need to append the array, use JSON.stringify() method to convert your array into a valid JSON string.
Here is how:
formData.append('user', JSON.stringify(body['user']));
Here you can read more about JavaScript's JSON object.
I had similar problem and I had declare array in key. For your example it would looks like this:
formData.append('user[id]', body['user']['id']);
...
It can be usefull if you wanten't or you can't parse json on server site
I had to add four images to same formdata id. Below is my code
const files = event.target.files;
for(var i=0;i< files.length;i++){
this.formData.append("imgs",files[i]);
}
try like this.. it works in my project
var formData= new FormData();
for (let file of files) {
formData.append('photo[]', file);
}