import { Injectable } from '@angular/core';
import { Headers, Http, Response, URLSearchParams, RequestOptions } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import { PersonType } from '../services/persontype';
@Injectable()
export class UserLoginService{
userLoginInformation: PersonType[];
constructor(private _http: Http){ }
userAuthenticationMethod(uInfo: any): Observable<any[]>{
let headers = new Headers({ 'Content-Type': 'application/x-www-form-urlencoded' });
let options = new RequestOptions({ headers: headers });
let params: URLSearchParams = new URLSearchParams();
params.set('userName', uInfo.userName);// test name
// return this._http
// .get(this.userUrl, {search: params})
// .map((res: Response) => res.json())
// .catch(this.handleError);
return this._http
.post(this.userUrl, {search: params}, options)
.map((res: Response) => res.json())
.catch(this.handleError);
}//END - userAuthenticationMethod
private handleError(error: any) {
console.error('An error occurred1', error); // for demo purposes only
return Observable.throw(error.message || error);
}
}//END class