【发布时间】:2018-08-22 02:02:31
【问题描述】:
Angular 发送 http post 请求失败,我收到了这个错误:
解析http://axis2.icd.teradyne.com:8080/test时的Http失败
service.ts
currentUse(SVF){
//let options = {headers: new HttpHeaders({'Content-Type': 'application/json'})};
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
//'Access-Control-Allow-Origin':
})
};
httpOptions.headers.set('Access-Control-Allow-Origin','http://axis2.icd.teradyne.com:8080');
return this.http.post<any>('http://axis2.icd.teradyne.com:8080/test', SVF, httpOptions)
.pipe(catchError(this.handleError))
}
如果我使用邮递员发送请求,它可以工作。
这是邮递员的标题:
Access-Control-Allow-Origin →*
Content-Length →4
Content-Type →text/html; charset=utf-8
Date →Wed, 22 Aug 2018 01:09:10 GMT
Server →Werkzeug/0.14.1 Python/3.6.2
我想知道问题是否是因为 httpheader 的格式错误。但是不知道怎么才能让header和postman header一样
【问题讨论】:
标签: angular http-headers http-post postman