You are mixing classes: HttpHeaders comes with HttpClient , which replaces Http with 4.3.
Other 403 comments are worth exploring, but at least do the following:
import { HttpClient, HttpHeaders } from "@angular/common/http"; import { Observable } from 'rxjs/Observable'; import 'rxjs/add/operator/map' @Injectable() export class AuthenticationService { private _options = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) }; // Inject HttpClient, not Http constructor(private http: HttpClient) { } login(username: string, password: string) { return this.http.post('http://localhost:56451/map', { username, password }, this._options); } }
Please note that you can use the destruction destination in the body of the message (when the name of your object matches the name of the variable you are replacing it with).
msanford Nov 02 '17 at 19:11 2017-11-02 19:11
source share