Return json api on Ionic 3

Asked

Viewed 229 times

1

I have the following problem, I am using a api ,that I created , when I use the method find me step one email and he returns to me if he found the email and 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

1 answer

0

The problem lies precisely in your amendment:

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

You named it after this.listaContas and is throwing the date into it and not to this.listaContas.email. When you try to access the property this.listaContas.email there is no.

Try it like this:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.