How use formData.append for a array in typescript

后端 未结 4 584
别那么骄傲
别那么骄傲 2021-01-18 06:09

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

4条回答
  •  耶瑟儿~
    2021-01-18 06:58

    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.

提交回复
热议问题