Inside my logincomponent
this.authenticationService.login('user', 'password').subscribe(comments => {
alert('success');
});
Inside my AuthService:
login(username: string, password: string) {
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
let url = 'http://22.5.66.58/api/v1/Identity/Login';
console.log(this.data);
return this.http.post(url, this.data, options).map((res: Response) => res.json());
}
It looks like your api route doesn't allow POST
method, but maybe only GET
or PUT
. You have to fix on the API (server) side.