[英]Angular form data to be sent in an array
I am sending a post request to the backend with just one input field and I able to display my request in console as "request".我只用一个输入字段向后端发送一个 post 请求,并且我能够在控制台中将我的请求显示为“请求”。 But the backend is expecting the request to be in an array like this ["request"].但是后端期望请求在这样的数组中 ["request"]。
Change this line:改变这一行:
this.verifyService.verify(this.hashForm.value)
To this:对此:
this.verifyService.verify([this.hashForm.value])
如果您的后端只需要string[]
值并且您的表单只有一个输入,则您可以执行类似的操作。
this.verifyService.verify([this.hashForm.controls.contentHash.value])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.