如何在angular2中以json的形式发送表单数据

时间:2016-09-13 11:25:38

标签: json angular typescript

我正在尝试将我的表单数据发送为json但是无法做到这一点可以请任何人帮助.... 我的,

   headers.append('Content-Type', 'application/x-www-form-urlencoded')
    this.http.post(this.header1+'login', JSON.stringify(form), { headers: headers })
        .subscribe(
        response => {
            if (response.json().error_code == 0) {
             //   console.log(response.json().data[0].profile_id);
                if (response.json().data[0].profile_id) {
                    localStorage.setItem('social', JSON.stringify(response.json().data[0]));
                }
                this.toastr.success('Loggedin successfully');
                this.router.navigate(['/demo/profile']);

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


}

但我无法看到任何数据从网络发送到服务器

1 个答案:

答案 0 :(得分:0)

我通过在node.js

中包含以下步骤来清除它
{{1}}
相关问题