Commit d17a153c authored by Gauri Amol Pande's avatar Gauri Amol Pande
Browse files

Merge branch '14-api-integration-for-registration' into 'master'

Resolve "Api Integration for  Registration"

Closes #14

See merge request 92khra1mst/hft_awado_app!7
parents e07d35f0 1bd118df
......@@ -29,7 +29,7 @@
</ion-item>
</div>
<div id="correctCredentialsmsg" padding *ngIf="correctCredentials">
<div id="correctCredentialsmsg" padding *ngIf="correctCredentials">
Wrong Credentials !
</div>
......
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import { RestService } from 'src/app/rest.service';
import { Router } from '@angular/router';
@Component({
selector: 'app-register',
......@@ -7,14 +10,33 @@ import { Observable } from 'rxjs';
styleUrls: ['./register.page.scss'],
})
export class RegisterPage implements OnInit {
httpClient: any;
registerApi: Observable<any>;
restService: any;
router: any;
correctCredentials: boolean;
constructor() { }
email: "";
password: "";
lastName: "";
firstName: "";
constructor(private router: Router, public httpClient: HttpClient, public restService: RestService) { }
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('/login');
}, (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