Check JSON result in Login with Angle 2x

0

My service to enter has:

entrar(data: any): Observable<any> {
  console.log(data.email, data.senha);
  return this.http.get('${this.baseUrl}/' + '?email=' + '${data.email}' + '&senha=' + '${data.senha}');  
}

And my login component the enter button has:

login() {
    this.jogadorService.entrar(this.user)
        .subscribe(() => {
            this.jogadorService.entrar(this.user);          
            alert('Login feito');
            //this.router.navigate(['/login'])
        });
  }

But he accepts any data. I wanted to check if user and password even exist and are the same. And if you return the empty JSON {} then show message.

How can I do this?

Taking advantage of the space, if the result is correct store the result in LocalStorage.

    
asked by anonymous 27.11.2018 / 16:42

0 answers