Commit f38dbf6a authored by gap95's avatar gap95
Browse files

Api Integrated for registration button

parent f815aaa4
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import { RestService } from 'src/app/rest.service';
import { Router } from '@angular/router';
@Component({ @Component({
selector: 'app-register', selector: 'app-register',
...@@ -7,14 +10,33 @@ import { Observable } from 'rxjs'; ...@@ -7,14 +10,33 @@ import { Observable } from 'rxjs';
styleUrls: ['./register.page.scss'], styleUrls: ['./register.page.scss'],
}) })
export class RegisterPage implements OnInit { export class RegisterPage implements OnInit {
httpClient: any;
registerApi: Observable<any>; registerApi: Observable<any>;
restService: any;
router: any;
correctCredentials: boolean; correctCredentials: boolean;
constructor() { } email: "";
password: "";
lastName: "";
firstName: "";
constructor(private router: Router, public httpClient: HttpClient, public restService: RestService) { }
ngOnInit() { ngOnInit() {
} }
submitRegister() {
this.registerApi = this.httpClient.post('http://193.196.52.237:8081/register', {
"email": this.email,
"password": this.password,
"firstname": this.firstName,
"lastname": this.lastName
});
this.registerApi
.subscribe((data) => {
console.log('my data: ', data);
this.restService.setToken(data.token);
this.router.navigateByUrl('/home');
}, (error) => {
console.log(error);
this.correctCredentials = true;
});
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment