小编pal*_*lak的帖子

如何在angular2中将标题设置为application/json

我正在尝试在 Angular2 中发送 HTTP post 请求,但无法将标头设置为内容类型应用程序 JSON。

我的代码是:

login(url,postdata)
{
    var headers = new Headers({'Content-Type': 'application/json'});
    return this._http.post(url,JSON.stringify(postdata),this.headers)
    .map(res => res.json())    
}
Run Code Online (Sandbox Code Playgroud)

当我检查网络时,我发现 Content-Type 设置为文本/纯文本,因此服务器没有接收任何数据。任何建议将不胜感激。

post header typescript angular

1
推荐指数
1
解决办法
2万
查看次数

标签 统计

angular ×1

header ×1

post ×1

typescript ×1