Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export class LoginComponent{
- title = 'Login';
- email = '';
- password = '';
- credentials = '';
- basic = '';
- constructor(private http:HttpClient){
- }
- createAuthorizationHeader(headers:Headers,basic){
- headers.append('Authorization',basic);
- }
- login(event){
- this.email = (<HTMLInputElement>document.getElementById("email")).value;
- this.password = (<HTMLInputElement>document.getElementById("password")).value;
- this.credentials = this.email + ":" + this.password;
- this.basic = "Basic " + btoa(this.credentials);
- console.log(this.basic);
- let headers = new Headers();
- headers.append('Content-Type','application/json');
- headers.append('Authorization',this.basic);
- let options = new RequestOptions({headers:headers});
- console.log(headers);
- return this.http.post('http://localhost:8000/api/v1/authenticate',options)
- .subscribe(
- res =>{
- console.log(res);
- },
- err => {
- console.log(err.message);
- }
- )
- }
- }
Add Comment
Please, Sign In to add comment