向Angular HttpClient添加HTTP标头不发送标头,为什么?
这是我的代码: import { HttpClient, HttpErrorResponse, HttpHeaders } from '@angular/common/http'; logIn(username: string, password: string) { const url = 'http://server.com/index.php'; const body = JSON.stringify({username: username, password: password}); const headers = new HttpHeaders(); headers.set('Content-Type', 'application/json; charset=utf-8'); this.http.post(url, body, {headers: headers}).subscribe( (data) => { console.log(data); }, (err: HttpErrorResponse) => { if (err.error instanceof Error) …