Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角度http post参数_Angular_Parameters_Http Post - Fatal编程技术网

Angular 角度http post参数

Angular 角度http post参数,angular,parameters,http-post,Angular,Parameters,Http Post,我向RESTAPI发送了一个post请求,如下所示 this._http.post(full, this.user, this.options) .toPromise() .then(success => { this.onSuccess(success); }, error => { this.onError(error); }); 请求工作正常,但服务器的响应不好,因为参数是这样发送的: 已尝试使

我向RESTAPI发送了一个post请求,如下所示

this._http.post(full, this.user, this.options)
      .toPromise()
      .then(success => {
        this.onSuccess(success);
      }, error => {
        this.onError(error);
      });
请求工作正常,但服务器的响应不好,因为参数是这样发送的:

已尝试使用JSON.stringify,未做任何更改

如何格式化数据? 有人有这个问题吗

提前谢谢

这是宣言

public user: any;
在建造商内部:

this.user = {
      "email: null,
      "password": null,
      "remember": false
    }

使用rxjs中的
map
运算符将响应转换为json

this._http.post(full, this.user, this.options)
          .map(res=> res.json())
          .toPromise()
          .then(success => { },
                error => {}
          );

使用rxjs中的
map
运算符将响应转换为json

this._http.post(full, this.user, this.options)
          .map(res=> res.json())
          .toPromise()
          .then(success => { },
                error => {}
          );

不,这不改变参数格式@AravindI没有明白,你能详细说明一下吗?我在post请求中发送的参数格式不正确,如图所示。我是从控制台得到的,由于格式错误,服务器拒绝了状态为400@AravindNope的请求,所以参数格式没有改变@AravindI没有明白,你能详细说明一下吗?我在post请求中发送的参数格式不正确,如图所示。我是从控制台得到的,由于格式错误,服务器拒绝了状态为400@Aravindc的请求,您可以显示用户模型的代码吗?@VitaliiChmovzh电子邮件、密码和记住。我理解。我能看看你在哪里声明的代码吗?@VitaliiChmovzh用变量声明和构造函数中的asignation编辑了这个问题。我唯一的想法是尝试给你的用户实际的类型,例如用
{email:string;password:string;membere:boolean}
和构造函数声明一个类用户。构建类并将其传递给http.post。我还要检查请求内容类型。您使用什么软件检查参数格式?我以前从未见过这样的问题。你能显示用户模型的代码吗?@VitaliiChmovzh电子邮件,密码和记住。我理解。我能看看你在哪里声明的代码吗?@VitaliiChmovzh用变量声明和构造函数中的asignation编辑了这个问题。我唯一的想法是尝试给你的用户实际的类型,例如用
{email:string;password:string;membere:boolean}
和构造函数声明一个类用户。构建类并将其传递给http.post。我还要检查请求内容类型。您使用什么软件检查参数格式?我以前从未见过这样的问题。。