0
我如何可以設置httpheaders,我添加以下代碼角4.3 HttpClient的不發送內容類型標題
public post (servicio: string, item: any): Observable<any>
{
const url = `${SERVER_URL}${servicio}`;
const headers = new HttpHeaders().set('Content-Type', 'application/json; charset=utf-8')
return this.http.post(url, item, {headers: headers})
.do(data => console.log('All: ' + JSON.stringify(data)))
.catch(this.handleError);
}
在Chrome或提琴手的請求
Accept:*/*
Accept-Encoding:gzip, deflate, br
Accept-Language:es-ES,es;q=0.8,en;q=0.6
Access-Control-Request-Headers:content-type
Access-Control-Request-Method:POST
Connection:keep-alive
Host:localhost:56962
Origin:http://evil.com/
Referer:http://localhost:4200/entidad
User-Agent:Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Mobile Safari/537.36
這是什麼類型的this.http? HttpClient的? –
[Angular \ [4.3 \] HttpClient不能發送頭文件的可能的副本](https://stackoverflow.com/questions/45286764/angular-4-3-httpclient-doesnt-send-header) –