Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.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
Http 在Angular 2中重新创建邮递员设置_Http_Angular_Postman - Fatal编程技术网

Http 在Angular 2中重新创建邮递员设置

Http 在Angular 2中重新创建邮递员设置,http,angular,postman,Http,Angular,Postman,我正在尝试从POSTMAN重新创建这些设置,这些设置允许我成功地对服务器进行身份验证。然而,在Angular 2中,我不知道如何使用“application/json”设置这个“raw”设置,因为它需要在两个地方:一个在头中,一个在正文中 这些单选按钮只是请求预览的设置。实际数据以JSON的形式从您指定的客户端(服务器也是这样接收的)发送到: this.headers.append('Content-Type', 'application/json'); 要以纯文本形式发送数据,您应如下设置

我正在尝试从POSTMAN重新创建这些设置,这些设置允许我成功地对服务器进行身份验证。然而,在Angular 2中,我不知道如何使用“application/json”设置这个“raw”设置,因为它需要在两个地方:一个在头中,一个在正文中


这些单选按钮只是请求预览的设置。实际数据以JSON的形式从您指定的客户端(服务器也是这样接收的)发送到:

this.headers.append('Content-Type', 'application/json');
要以纯文本形式发送数据,您应如下设置
内容类型
标题:

this.headers.append('Content-Type', 'text/plain');
源标题:

this.headers.append('Access-Control-Allow-Origin', 'http://api:8080');

此处无效,您应该在服务器端设置
访问控制允许源文件。

它们是两个独立的文件。我通过
this.config
访问所有配置。只是当我将JSON(应用程序/文本)更改为其他内容时,它会给我一个错误:Status 422 Unprocessable Entity
JSON(应用程序/文本)
?不知道你想做什么。对不起,我是说
JSON(application/JSON)
this.headers.append('Content-Type','text/plain')这就是你要找的吗?如果可能的话,我需要在Postman中使用Angular 2(特别是“原始”部分)重新创建这些设置
this.headers.append('Access-Control-Allow-Origin', 'http://api:8080');