Return json api no ionic 3

1

I have the following problem, I am using a api , which I created, when I use the method find I pass email and it returns me if found email e senha

Method

 buscarEmail(){
    this.webservice.findConta(this.email).subscribe(data=>  {
        this.listaContas = data ;
        console.log(this.listaContas);

});

console.log

[Array(1)] 0 :
Array(1) 0:
{id: 7, email: "[email protected]", senha: "4154512"}
length:1

but when I try to access

Method

buscarEmail(){
    this.webservice.findConta(this.email).subscribe(data=>  {
        this.listaContas = data ;
        console.log(this.listaContas.email); //alteirei para .email

});

console.log

undefined
    
asked by anonymous 09.03.2018 / 15:00

1 answer

0

The problem is precisely in its change:

    buscarEmail(){
this.webservice.findConta(this.email).subscribe(data=>  {
    this.listaContas = data ;
    console.log(this.listaContas.email); //alteirei para .email
});

You have put the name of this.listaContas and you are throwing the date into it and not to this.listaContas.email . When you try to access the this.listaContas.email property, it does not exist.

Try this:

buscarEmail(){
this.webservice.findConta(this.email).subscribe(data=>  {
    this.listaContas.email = data ;
    console.log(this.listaContas.email); //alteirei para .email
});
    
09.03.2018 / 19:53