【发布时间】:2021-11-24 20:55:20
【问题描述】:
我有以下方法,我试图将一些值作为列表发送到我的后端。接受的json格式如下:
{
value: [xyz]
}
但现在我只将 xyz 部分作为单个值发送到我的后端,但我需要将它作为所示部分发送。 我的看起来像这样:xyz 根据发送到我控制台中网络后端的有效负载。
这是我用来将这些发送到后端的函数:
setValueForTest() {
this.personArray = this.form.controls.selectBox.value;
this.personArraySave = []
this.personArray.forEach((id) => {
this.personArraySave.push(id)
this.api.setValueForPerson({
body: id
).subscribe(response => {
console.log(response)
});
}
});
}
body 和 personArraySave 来自 Person 类型,只有 id: Array 作为属性
【问题讨论】:
标签: javascript angular typescript