1

I've been trying to display some data from a web service with no luck I tried this

ngOnInit(){
    //console.log(this._productoService.getDeudas());
    this._productoService.getDeudas().subscribe(
      result =>{
        console.log(result.Cuotas);       
      }
    );
  }
}

and i got this error

 Property 'Cuotas' does not exist on type 'Response'.

this is the data i got in the console

enter image description here

any ideas? thanks in advance

2
  • 1
    Does this work: result => { result ['Cuotas']; } ? Commented Sep 4, 2017 at 2:35
  • @Zze Awesome It works!!! thanks dude, didn't realize it was an array. Commented Sep 4, 2017 at 2:40

1 Answer 1

1

Response is an object and therefore you can use...

result => { result ['Cuotas']; }

... the [result ['Cuotas']] field access stands out because you use bracket notation to access the results field. If you tried to write [result.Cuotas], TypeScript would correctly complain that the Object coming back from HTTP does not have a results property. That's because while HttpClient parsed the JSON response into an Object, it doesn't know what shape that object is.

https://angular.io/guide/http

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.