diff --git a/src/app/api.service.ts b/src/app/api.service.ts index b9bd55d..b3c7cf4 100644 --- a/src/app/api.service.ts +++ b/src/app/api.service.ts @@ -21,9 +21,11 @@ export class ApiService { validateUser(user: UserLogin): Observable{ - return this.http.post("http://localhost:3307/api/consultas/users", user); + return this.http.post("http://localhost:3307/api/consultas/users", user) + } + } diff --git a/src/app/login.service.ts b/src/app/login.service.ts index beaf043..1b7225a 100644 --- a/src/app/login.service.ts +++ b/src/app/login.service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; import { Router } from '@angular/router'; +import { VirtualTimeScheduler } from 'rxjs'; import { ApiService } from './api.service'; import { User } from './user'; import { UserLogin } from './user-login'; @@ -21,7 +22,7 @@ export class LoginService { }; } - validateUser(login: string, password: string): User { + validateUser(login: string, password: string): void{ let userlogin: UserLogin = { loginUser: login, @@ -29,12 +30,12 @@ export class LoginService { } this.apiService.validateUser(userlogin) - .subscribe(user => this.user = user) - - return this.user; + .subscribe(user => { + this.user = user; + console.log(this.user); + }) } - } diff --git a/src/app/login/login.page.ts b/src/app/login/login.page.ts index f8de934..3016ca9 100644 --- a/src/app/login/login.page.ts +++ b/src/app/login/login.page.ts @@ -20,12 +20,12 @@ export class LoginPage implements OnInit { this.user = this.loginService.user; } - async login() { + login() { this.username = (document.getElementById("username")).value; this.password = (document.getElementById("password")).value; - this.user = await this.loginService.validateUser(this.username, this.password); - console.log(this.user.username); + this.loginService.validateUser(this.username, this.password) + }