admin管理员组文章数量:1326112
how to append the nested object in FormData, my object is
{
name: 'test',
phone: '454353',
address: [
{
state: 'ewrwer',
city: 'asdasd'
}
]
}
I had append like this
const data = new FormData();
data.append("name", "test");
data.append("phone", "454353");
data.append("address['state']", "ewrwer");
data.append("address['city']", "asdasd");
but this is not working for me when I send this formData in request body the address is not working.
how to append the nested object in FormData, my object is
{
name: 'test',
phone: '454353',
address: [
{
state: 'ewrwer',
city: 'asdasd'
}
]
}
I had append like this
const data = new FormData();
data.append("name", "test");
data.append("phone", "454353");
data.append("address['state']", "ewrwer");
data.append("address['city']", "asdasd");
but this is not working for me when I send this formData in request body the address is not working.
Share Improve this question asked May 13, 2020 at 10:29 user9361329user93613291 Answer
Reset to default 7It should be:
data.append("address[0]['state']", "ewrwer");
data.append("address[0]['city']", "asdasd");
Because, it is inside array of index 0, then inside that you have addresses.
本文标签: multipartform datahow to form the nested object in Formdata in javascriptStack Overflow
版权声明:本文标题:multipartform data - how to form the nested object in Formdata in javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742192869a2430537.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论