简体   繁体   English

要在数组中发送的角度形式数据

[英]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.

相关问题 绑定数据以形成角度数组 - binding data to form array in angular 接收由jQuery发送并由Node Js接收为JSON的数组形式数据 - Receiving array form data as JSON sent by jQuery and received by Node Js 在Angular和Typescript中将表单数组数据转换为Json - Transform a form array data to Json in Angular and Typescript 表单数据未发送到服务器 - Form data not being sent to the server 有没有最佳实践来防止我的Angular SPA的用户在将请求中的表单数据发送到服务器之前对其进行操作 - Is there a best practice to prevent the user of my Angular SPA to manipulate the Form-Data in a Request before it is sent to the server Angular httpClient如何发送图像和JSON - How sent image and JSON form Angular httpClient 通过AJAX将Codeigniter中的表单数据发送到Controller函数,该Controller函数查询数据库并返回数组 - Form data in Codeigniter sent via AJAX to a Controller function that queries a database and returns an array 如何将数据从Angular表单推入(数组)队列 - How to push data from Angular form into (array)queue 将表单数据保存在包含数组 [Angular] 的模态 class 中 - Save form data in modal class that contains an array [Angular] angular 中的嵌套表单数组 - Nested form array in angular
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM