tokenType = 'Bearer ';
loginUser(data: Student): Observable<any> {
const url = '/login';
const header = new HttpHeaders().set('Authorization', this.tokenType + this.cookieService.get('token')); // may be localStorage/sessionStorage
const headers = { headers: header };
return this.httpClient.post(this.serverUrl + url, data, headers);
}
getuserInfo(): Observable<any> {
const url = '/userinfo';
const header = new HttpHeaders().set('Authorization', this.tokenType + this.cookieService.get('token')); // may be localStorage/sessionStorage
const headers = { headers: header };
return this.httpClient.get(this.serverUrl + url,headers);
}
submitForm(submission: any): void {
console.log(submission);
if (submission && submission.submit) {
delete submission.submit;
}
this.loginService.loginUser(submission)
.subscribe(result => {
console.log(result);
this.userinfo();
}, err => {
alert(err);
});
}
userinfo() {
this.loginService.getuserInfo()
.subscribe(result => {
console.log(result);
}, err => {
alert(err);
});
}