如何订阅节点服务器的响应

时间:2016-09-13 12:56:57

标签: node.js angular

我正在尝试订阅我的节点服务器reslut,我试着跟随 我的,

 .subscribe(
        response => {
            if (response.json().result == 'success') {
                this.toastr.success('Loggedin successfully');
                this.router.navigate(['/demo/profile']);

            }
            else {
                this.toastr.error('Email or Password is wrong');
            }
        });

我的服务器响应,

  {
  "status": "success",
  "result": [
    {
      "profile_id": 1,
      "firstname": "Sachin",
      "repeatpassword": null,
      "type": null,
      "connection_status": null,
      "relation_id": null
    }
  ]
}

有人可以帮助我

1 个答案:

答案 0 :(得分:1)

更改您的订阅代码如下:

subscribe(
        response => {
            if (response.json().status == 'success') {
                this.toastr.success('Loggedin successfully');
                this.router.navigate(['/demo/profile']);

            }
            else {
                this.toastr.error('Email or Password is wrong');
            }
        });